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

develop-docs/integrations/index.mdx

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

docs/api/index.mdx

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

56
The Sentry web API is used to access the Sentry platform programmatically. You can use the APIs to manage account-level resources, like organizations and teams, as well as manage and export data.

docs/cli/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Sentry CLI"
3-
sidebar_order: 4000
3+
sidebar_order: 50
44
keywords:
55
[
66
"cli",

docs/concepts/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Concepts & Reference
3-
sidebar_order: 160
3+
sidebar_order: 80
44
description: "Learn the basic concepts of Sentry such as searchable properties and data management settings."
55
---
66

docs/contributing/pages/frontmatter.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,13 @@ Much of the other functionality for pages is also driven via frontmatter, such a
4747

4848
- [Redirects](../redirects/)
4949
- [Search](../search/)
50+
51+
`nextPage` (`{ path: 'path/to/page', title: 'Page Title' }`)
52+
53+
Overrides the next page shown in the bottom pagination navigation.
54+
55+
`previousPage` (`{ path: 'path/to/page', title: 'Page Title' }`)
56+
57+
Overrides the previous page shown in the bottom pagination navigation.
58+
59+

docs/organization/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Organization Settings
3-
sidebar_order: 400
3+
sidebar_order: 20
44
description: "Learn how to configure your organization's Sentry account, including 2FA authentication, user management, and data storage location."
55
---
66

docs/pricing/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Pricing & Billing
3-
sidebar_order: 1
3+
sidebar_order: 40
44
description: "Learn about pricing, managing volume, and the different Sentry plans."
55
---
66

docs/product/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Product Walkthroughs
3-
sidebar_order: 1
3+
sidebar_order: 30
44
description: "Get an overview of how you can use Sentry to not just observe, but debug errors, get to the root of user complaints, and identify performance bottlenecks."
55
---
66

docs/security-legal-pii/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Security, Legal, & PII
3-
sidebar_order: 1
3+
sidebar_order: 70
44
description: "Learn about Sentry's security and compliance processes and how to scrub sensitive data."
55
---
66

src/components/docPage/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {ReactNode} from 'react';
33
import {getCurrentGuide, getCurrentPlatform, nodeForPath} from 'sentry-docs/docTree';
44
import {serverContext} from 'sentry-docs/serverContext';
55
import {FrontMatter} from 'sentry-docs/types';
6+
import {PaginationNavNode} from 'sentry-docs/types/paginationNavNode';
67
import {isTruthy} from 'sentry-docs/utils';
78
import {getUnversionedPath} from 'sentry-docs/versioning';
89

@@ -12,6 +13,7 @@ import {Breadcrumbs} from '../breadcrumbs';
1213
import {CodeContextProvider} from '../codeContext';
1314
import {GitHubCTA} from '../githubCTA';
1415
import {Header} from '../header';
16+
import {PaginationNav} from '../paginationNav';
1517
import {PlatformSdkDetail} from '../platformSdkDetail';
1618
import {Sidebar} from '../sidebar';
1719
import {TableOfContents} from '../tableOfContents';
@@ -21,8 +23,10 @@ type Props = {
2123
frontMatter: Omit<FrontMatter, 'slug'>;
2224
/** Whether to take all the available width */
2325
fullWidth?: boolean;
26+
nextPage?: PaginationNavNode;
2427
/** Whether to hide the table of contents & sdk details */
2528
notoc?: boolean;
29+
previousPage?: PaginationNavNode;
2630
sidebar?: ReactNode;
2731
};
2832

@@ -32,6 +36,8 @@ export function DocPage({
3236
notoc = false,
3337
fullWidth = false,
3438
sidebar,
39+
nextPage,
40+
previousPage,
3541
}: Props) {
3642
const {rootNode, path} = serverContext();
3743
const currentPlatform = getCurrentPlatform(rootNode, path);
@@ -78,6 +84,16 @@ export function DocPage({
7884
<div id="main">
7985
<CodeContextProvider>{children}</CodeContextProvider>
8086
</div>
87+
88+
<div className="grid grid-cols-2 gap-4 not-prose mt-16">
89+
<div className="col-span-1">
90+
{previousPage && <PaginationNav node={previousPage} title="Previous" />}
91+
</div>
92+
<div className="col-span-1">
93+
{nextPage && <PaginationNav node={nextPage} title="Next" />}
94+
</div>
95+
</div>
96+
8197
{hasGithub && <GitHubCTA />}
8298
</div>
8399
</div>

src/components/githubCTA/styles.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.cta {
22
background: var(--accent-a2);
3-
margin-top: 4rem;
3+
margin-top: 2rem;
44
margin-bottom: 2rem;
55
padding: 1rem 1.25rem;
66
border-radius: 0.25em;

src/components/paginationNav.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {DoubleArrowLeftIcon, DoubleArrowRightIcon} from '@radix-ui/react-icons';
2+
3+
import {PaginationNavNode} from 'sentry-docs/types/paginationNavNode';
4+
5+
export function PaginationNav({
6+
node,
7+
title,
8+
}: {
9+
node: PaginationNavNode;
10+
title: 'Previous' | 'Next';
11+
}) {
12+
return (
13+
<a href={`/${node.path}`} className="no-underline">
14+
<div
15+
className={`py-3 px-4 border-2 dark:[border-color:var(--gray-4)] rounded-md transition-colors hover:[border-color:var(--accent)] ${
16+
title === 'Previous' ? 'text-left' : 'text-right'
17+
}`}
18+
>
19+
<div className="text-sm [color:var(--foreground)]">{title}</div>
20+
<div
21+
className={`flex items-center gap-1 font-[500] ${
22+
title === 'Previous' ? 'justify-start' : 'justify-end'
23+
}`}
24+
>
25+
{title === 'Previous' && <DoubleArrowLeftIcon />}
26+
27+
{node.title}
28+
29+
{title === 'Next' && <DoubleArrowRightIcon />}
30+
</div>
31+
</div>
32+
</a>
33+
);
34+
}

src/components/sidebar/sidebarLinks.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {NavNode} from './types';
1111
import {docNodeToNavNode, getNavNodes} from './utils';
1212

1313
/** a root of `"some-root"` maps to the `/some-root/` url */
14+
// todo: we should probably get rid of this
1415
const productSidebarItems = [
1516
{
1617
title: 'Account Settings',

0 commit comments

Comments
 (0)