Skip to content

Commit 9e52aba

Browse files
Merge pull request #131 from neherlab/docs/custom-404-page
docs: customize "not found" (404) page
2 parents a9a322e + c6339a3 commit 9e52aba

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

Diff for: docs/src/theme/NotFound/Content/index.tsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import Translate from '@docusaurus/Translate';
4+
import type { Props } from '@theme/NotFound/Content';
5+
import Heading from '@theme/Heading';
6+
import Link from '@docusaurus/Link';
7+
8+
export default function NotFoundContent({ className }: Props): JSX.Element {
9+
return (
10+
<main className={clsx('container margin-vert--xl', className)}>
11+
<div className="row">
12+
<div className="col col--6 col--offset-3">
13+
<Heading as="h1" className="hero__title">
14+
<Translate id="theme.NotFound.title" description="The title of the 404 page">
15+
Page Not Found
16+
</Translate>
17+
</Heading>
18+
<p>
19+
<Translate id="theme.NotFound.p1" description="The first paragraph of the 404 page">
20+
We could not find what you were looking for.
21+
</Translate>
22+
</p>
23+
<p>
24+
<Translate>{"If you believe it's a bug, please report it at "}</Translate>
25+
<a href="https://github.com/neherlab/pangraph/issues" target="_blank" rel="noopener noreferrer">
26+
github.com/neherlab/pangraph/issues
27+
</a>
28+
</p>
29+
30+
<Link to="/" className="button button--primary button--lg">
31+
<Translate>{'Go to main page'}</Translate>
32+
</Link>
33+
</div>
34+
</div>
35+
</main>
36+
);
37+
}

Diff for: docs/src/theme/NotFound/index.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import { translate } from '@docusaurus/Translate';
3+
import { PageMetadata } from '@docusaurus/theme-common';
4+
import Layout from '@theme/Layout';
5+
import NotFoundContent from '@theme/NotFound/Content';
6+
7+
/**
8+
* Customized 404 page.
9+
*
10+
* Swizzled (ejected) from the original theme using:
11+
*
12+
* ```bash
13+
* bun run swizzle --typescript --eject @docusaurus/theme-classic NotFound
14+
* ```
15+
*
16+
* */
17+
export default function Index(): JSX.Element {
18+
const title = translate({
19+
id: 'theme.NotFound.title',
20+
message: 'Page Not Found',
21+
});
22+
return (
23+
<>
24+
<PageMetadata title={title} />
25+
<Layout>
26+
<NotFoundContent />
27+
</Layout>
28+
</>
29+
);
30+
}

0 commit comments

Comments
 (0)