Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Format apple platform names in metadata #11130

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading