Skip to content

Commit 4228c99

Browse files
authored
feat(platform): Navigation buttons (#11639)
1 parent fe05be6 commit 4228c99

File tree

26 files changed

+499
-33
lines changed

26 files changed

+499
-33
lines changed

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

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import {Home} from 'sentry-docs/components/home';
1111
import {Include} from 'sentry-docs/components/include';
1212
import {PlatformContent} from 'sentry-docs/components/platformContent';
1313
import {
14+
DocNode,
1415
getCurrentPlatformOrGuide,
1516
getDocsRootNode,
17+
getNextNode,
18+
getPreviousNode,
1619
nodeForPath,
1720
} from 'sentry-docs/docTree';
1821
import {isDeveloperDocs} from 'sentry-docs/isDeveloperDocs';
@@ -24,6 +27,7 @@ import {
2427
} from 'sentry-docs/mdx';
2528
import {mdxComponents} from 'sentry-docs/mdxComponents';
2629
import {setServerContext} from 'sentry-docs/serverContext';
30+
import {PaginationNavNode} from 'sentry-docs/types/paginationNavNode';
2731
import {stripVersion} from 'sentry-docs/versioning';
2832

2933
export async function generateStaticParams() {
@@ -42,7 +46,11 @@ export const dynamic = 'force-static';
4246

4347
const mdxComponentsWithWrapper = mdxComponents(
4448
{Include, PlatformContent},
45-
({children, frontMatter}) => <DocPage frontMatter={frontMatter}>{children}</DocPage>
49+
({children, frontMatter, nextPage, previousPage}) => (
50+
<DocPage frontMatter={frontMatter} nextPage={nextPage} previousPage={previousPage}>
51+
{children}
52+
</DocPage>
53+
)
4654
);
4755

4856
function MDXLayoutRenderer({mdxSource, ...rest}) {
@@ -59,6 +67,42 @@ export default async function Page({params}: {params: {path?: string[]}}) {
5967
path: params.path ?? [],
6068
});
6169

70+
if (!params.path && !isDeveloperDocs) {
71+
return <Home />;
72+
}
73+
74+
const pageNode = nodeForPath(rootNode, params.path ?? '');
75+
76+
if (!pageNode) {
77+
// eslint-disable-next-line no-console
78+
console.warn('no page node', params.path);
79+
return notFound();
80+
}
81+
82+
// gather previous and next page that will be displayed in the bottom pagination
83+
const getPaginationDetails = (
84+
getNode: (node: DocNode) => DocNode | undefined | 'root',
85+
page: PaginationNavNode | undefined
86+
) => {
87+
if (page && 'path' in page && 'title' in page) {
88+
return page;
89+
}
90+
91+
const node = getNode(pageNode);
92+
93+
if (node === 'root') {
94+
return {path: '', title: 'Welcome to Sentry'};
95+
}
96+
97+
return node ? {path: node.path, title: node.frontmatter.title} : undefined;
98+
};
99+
100+
const previousPage = getPaginationDetails(
101+
getPreviousNode,
102+
pageNode?.frontmatter?.previousPage
103+
);
104+
const nextPage = getPaginationDetails(getNextNode, pageNode?.frontmatter?.nextPage);
105+
62106
if (isDeveloperDocs) {
63107
// get the MDX for the current doc and render it
64108
let doc: Awaited<ReturnType<typeof getFileBySlug>> | null = null;
@@ -74,13 +118,17 @@ export default async function Page({params}: {params: {path?: string[]}}) {
74118
}
75119
const {mdxSource, frontMatter} = doc;
76120
// pass frontmatter tree into sidebar, rendered page + fm into middle, headers into toc
77-
return <MDXLayoutRenderer mdxSource={mdxSource} frontMatter={frontMatter} />;
78-
}
79-
if (!params.path) {
80-
return <Home />;
121+
return (
122+
<MDXLayoutRenderer
123+
mdxSource={mdxSource}
124+
frontMatter={frontMatter}
125+
nextPage={nextPage}
126+
previousPage={previousPage}
127+
/>
128+
);
81129
}
82130

83-
if (params.path[0] === 'api' && params.path.length > 1) {
131+
if (params.path?.[0] === 'api' && params.path.length > 1) {
84132
const categories = await apiCategories();
85133
const category = categories.find(c => c.slug === params?.path?.[1]);
86134
if (category) {
@@ -94,14 +142,6 @@ export default async function Page({params}: {params: {path?: string[]}}) {
94142
}
95143
}
96144

97-
const pageNode = nodeForPath(rootNode, params.path);
98-
99-
if (!pageNode) {
100-
// eslint-disable-next-line no-console
101-
console.warn('no page node', params.path);
102-
return notFound();
103-
}
104-
105145
// get the MDX for the current doc and render it
106146
let doc: Awaited<ReturnType<typeof getFileBySlug>> | null = null;
107147
try {
@@ -122,7 +162,12 @@ export default async function Page({params}: {params: {path?: string[]}}) {
122162

123163
// pass frontmatter tree into sidebar, rendered page + fm into middle, headers into toc.
124164
return (
125-
<MDXLayoutRenderer mdxSource={mdxSource} frontMatter={{...frontMatter, versions}} />
165+
<MDXLayoutRenderer
166+
mdxSource={mdxSource}
167+
frontMatter={{...frontMatter, versions}}
168+
nextPage={nextPage}
169+
previousPage={previousPage}
170+
/>
126171
);
127172
}
128173

develop-docs/application/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Application
3+
sidebar_order: 30
34
---
45

56
<PageGrid />

develop-docs/development/environment/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Environment
33
description: This guide steps you through configuring a local development environment for the Sentry server on macOS and Linux.
4-
sidebar_order: 1
4+
sidebar_order: 2
55
---
66

77
If you're using
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Developing Integrations
3-
sidebar_order: 80
3+
sidebar_order: 90
44
---
55

66
<PageGrid />

develop-docs/relay/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Relay Development
3-
sidebar_order: 60
3+
sidebar_order: 70
44
---
55

66
Relay is a service for event filtering, rate-limiting and processing. It can act as:

develop-docs/sdk/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: SDK Development
3-
sidebar_order: 70
3+
sidebar_order: 60
44
---
55

66
The following is a guide for implementing a Sentry SDK.

develop-docs/self-hosted/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Self-Hosted Sentry
3-
sidebar_order: 30
3+
sidebar_order: 100
44
---
55

66
In addition to making its source code available publicly, Sentry offers and maintains a minimal setup that works out-of-the-box for simple use cases. This version comes with no guarantees or dedicated support. Sentry engineers will do their best to answer questions and are dedicated to making sure self-hosted is running, but that's where our involvement ends. For anything else, we expect users to rely on the [Sentry Self-Hosted community](https://discord.gg/sentry) on Discord. The self-hosted repository should serve as a blueprint for how various Sentry services connect for a complete setup. This will be useful for folks willing to maintain larger installations with custom infrastructure.

develop-docs/self-hosted/releases.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Self-Hosted Releases & Upgrading
33
sidebar_title: Releases & Upgrading
4-
sidebar_order: 10
4+
sidebar_order: 1
55
---
66

77
Sentry cuts regular releases for self-hosting to keep it as close to [sentry.io](https://sentry.io) as possible. We decided to follow a monthly release schedule using the [CalVer](https://calver.org/#scheme) versioning scheme, with a primary release on the [15th of each month](https://github.com/getsentry/self-hosted/blob/704e4c3b5b7360080f79bcfbe26583e5a95ae675/.github/workflows/release.yml#L20-L24). We don't patch old versions, but if a bug is bad enough we may cut an out-of-cycle point release, which, like our regular monthly releases, is a snapshot of the latest versions of all of our components. You can find the [latest release](https://github.com/getsentry/self-hosted/releases/latest) over at the [releases section of our self-hosted repository](https://github.com/getsentry/self-hosted/releases/).

develop-docs/services/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Services
3-
sidebar_order: 60
3+
sidebar_order: 80
44
---
55

66
<PageGrid />

docs/account/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Account Settings
3-
sidebar_order: 400
3+
sidebar_order: 10
44
description: "Learn about Sentry's user settings and auth tokens."
55
---
66

0 commit comments

Comments
 (0)