Skip to content

Commit

Permalink
fix: Format apple platform names in metadata (#11130)
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome committed Aug 22, 2024
1 parent 1f3bd20 commit 96e0273
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/[[...path]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
import {getDevDocsFrontMatter, getDocsFrontMatter, getFileBySlug} from 'sentry-docs/mdx';
import {mdxComponents} from 'sentry-docs/mdxComponents';
import {setServerContext} from 'sentry-docs/serverContext';
import {capitilize} from 'sentry-docs/utils';
import {formatGuideOrPlatformTitle} from 'sentry-docs/utils';

export async function generateStaticParams() {
const docs = await (isDeveloperDocs ? getDevDocsFrontMatter() : getDocsFrontMatter());
Expand Down Expand Up @@ -141,7 +141,9 @@ export async function generateMetadata({params}: MetadataProps): Promise<Metadat
const guideOrPlatform = getCurrentPlatformOrGuide(rootNode, params.path);
title =
pageNode.frontmatter.title +
(guideOrPlatform ? ` | Sentry for ${capitilize(guideOrPlatform.name)}` : '');
(guideOrPlatform
? ` | Sentry for ${formatGuideOrPlatformTitle(guideOrPlatform.name)}`
: '');
description = pageNode.frontmatter.description ?? '';
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,31 @@ export const capitilize = (str: string) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};

export const formatGuideOrPlatformTitle = (title: string) => {
const lowerCase = title.toLowerCase();
if (lowerCase === 'ios') {
return 'iOS';
}

if (lowerCase === 'macos') {
return 'macOS';
}

if (lowerCase === 'tvos') {
return 'tvOS';
}

if (lowerCase === 'visionos') {
return 'visionOS';
}

if (lowerCase === 'watchos') {
return 'watchOS';
}

return capitilize(title);
};

export const uniqByReference = <T>(arr: T[]): T[] => Array.from(new Set(arr));

export const splitToChunks = <T>(numChunks: number, arr: T[]): T[][] => {
Expand Down

0 comments on commit 96e0273

Please sign in to comment.