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

feat: append platform or guide name to page title #9351

Merged
merged 1 commit into from
Mar 8, 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
13 changes: 11 additions & 2 deletions app/[[...path]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import {DocPage} from 'sentry-docs/components/docPage';
import {Home} from 'sentry-docs/components/home';
import {Include} from 'sentry-docs/components/include';
import {PlatformContent} from 'sentry-docs/components/platformContent';
import {getDocsRootNode, nodeForPath} from 'sentry-docs/docTree';
import {
getCurrentPlatformOrGuide,
getDocsRootNode,
nodeForPath,
} from 'sentry-docs/docTree';
import {getDocsFrontMatter, getFileBySlug} from 'sentry-docs/mdx';
import {mdxComponents} from 'sentry-docs/mdxComponents';
import {setServerContext} from 'sentry-docs/serverContext';
import {capitilize} from 'sentry-docs/utils';

export async function generateStaticParams() {
const docs = await getDocsFrontMatter();
Expand Down Expand Up @@ -112,10 +117,14 @@ export async function generateMetadata({params}: MetadataProps): Promise<Metadat
const images = [{url: `${domain}/meta.png`, width: 1200, height: 630}];

const rootNode = await getDocsRootNode();

if (rootNode && params.path) {
const pageNode = nodeForPath(rootNode, params.path);
if (pageNode) {
title = pageNode.frontmatter.title;
const guideOrPlatform = getCurrentPlatformOrGuide(rootNode, params.path);
title =
pageNode.frontmatter.title +
(guideOrPlatform ? ` | Sentry for ${capitilize(guideOrPlatform.name)}` : '');
description = pageNode.frontmatter.description;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export function sortBy<A>(arr: A[], comp: (v: A) => number): A[] {
});
}

export const capitilize = (str: string) => {
return str.charAt(0).toUpperCase() + str.slice(1);
};

type Page = {
context: {
sidebar_order?: number;
Expand Down
Loading