Skip to content

Commit 27d09c2

Browse files
authored
feat(platform): Display requested title in platform redirect (#11646)
1 parent 8f6b52a commit 27d09c2

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Diff for: app/platform-redirect/page.tsx

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {redirect} from 'next/navigation';
22

3+
import {Alert} from 'sentry-docs/components/alert';
34
import {DocPage} from 'sentry-docs/components/docPage';
45
import {PlatformIcon} from 'sentry-docs/components/platformIcon';
56
import {SmartLink} from 'sentry-docs/components/smartLink';
@@ -14,16 +15,31 @@ export default async function Page({
1415
if (Array.isArray(next)) {
1516
next = next[0];
1617
}
18+
1719
// discard the hash
1820
const [pathname, _] = next.split('#');
1921
const rootNode = await getDocsRootNode();
22+
const defaultTitle = 'Platform Specific Content';
23+
let description = '';
24+
const platformInfo =
25+
"The page you are looking for is customized for each platform. Select your platform below and we'll direct you to the most specific documentation on it.";
26+
let title = defaultTitle;
27+
2028
// get rid of irrelevant platforms for the `next` path
2129
const platformList = extractPlatforms(rootNode).filter(platform_ => {
22-
return !!nodeForPath(rootNode, [
30+
const node = nodeForPath(rootNode, [
2331
'platforms',
2432
platform_.key,
2533
...pathname.split('/').filter(Boolean),
2634
]);
35+
36+
// extract title and description for displaying it on page
37+
if (node && title === defaultTitle && pathname.length > 0) {
38+
title = node.frontmatter.title ?? title;
39+
description = node.frontmatter.description || '';
40+
}
41+
42+
return !!node;
2743
});
2844

2945
if (platformList.length === 0) {
@@ -42,18 +58,16 @@ export default async function Page({
4258
}
4359

4460
const frontMatter = {
45-
title: 'Platform Specific Content',
61+
title,
62+
description,
4663
};
4764

4865
// make the Sidebar aware of the current path
4966
setServerContext({rootNode, path: ['platform-redirect']});
5067

5168
return (
5269
<DocPage frontMatter={frontMatter}>
53-
<p>
54-
The page you are looking for is customized for each platform. Select your platform
55-
below and we&apos;ll direct you to the most specific documentation on it.
56-
</p>
70+
<Alert level="info">{platformInfo}</Alert>
5771

5872
<ul>
5973
{platformList.map(p => (

0 commit comments

Comments
 (0)