Skip to content

Commit 070b25c

Browse files
authored
feat: append platform or guide indicator to page title (#9351)
1 parent 60c8564 commit 070b25c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

app/[[...path]]/page.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ import {DocPage} from 'sentry-docs/components/docPage';
1010
import {Home} from 'sentry-docs/components/home';
1111
import {Include} from 'sentry-docs/components/include';
1212
import {PlatformContent} from 'sentry-docs/components/platformContent';
13-
import {getDocsRootNode, nodeForPath} from 'sentry-docs/docTree';
13+
import {
14+
getCurrentPlatformOrGuide,
15+
getDocsRootNode,
16+
nodeForPath,
17+
} from 'sentry-docs/docTree';
1418
import {getDocsFrontMatter, getFileBySlug} from 'sentry-docs/mdx';
1519
import {mdxComponents} from 'sentry-docs/mdxComponents';
1620
import {setServerContext} from 'sentry-docs/serverContext';
21+
import {capitilize} from 'sentry-docs/utils';
1722

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

114119
const rootNode = await getDocsRootNode();
120+
115121
if (rootNode && params.path) {
116122
const pageNode = nodeForPath(rootNode, params.path);
117123
if (pageNode) {
118-
title = pageNode.frontmatter.title;
124+
const guideOrPlatform = getCurrentPlatformOrGuide(rootNode, params.path);
125+
title =
126+
pageNode.frontmatter.title +
127+
(guideOrPlatform ? ` | Sentry for ${capitilize(guideOrPlatform.name)}` : '');
119128
description = pageNode.frontmatter.description;
120129
}
121130
}

src/utils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export function sortBy<A>(arr: A[], comp: (v: A) => number): A[] {
1515
});
1616
}
1717

18+
export const capitilize = (str: string) => {
19+
return str.charAt(0).toUpperCase() + str.slice(1);
20+
};
21+
1822
type Page = {
1923
context: {
2024
sidebar_order?: number;

0 commit comments

Comments
 (0)