Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Hydration failed because the initial UI... while adding custom 404.mdx/500.mdx custom error pages #607

Merged
merged 5 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/docs/src/theme.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export default {
unstable_faviconGlyph: '✦',
prevLinks: true,
nextLinks: true,
floatTOC: true,
footer: true,
footerEditLink: 'Edit this page on GitHub',
footerText: `MIT ${new Date().getFullYear()} © Nextra.`,
Expand Down
3 changes: 1 addition & 2 deletions examples/swr-site/middleware.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import { locales } from "nextra/locales";
export const middleware = locales;
export { locales as middleware } from "nextra/locales";
5 changes: 5 additions & 0 deletions examples/swr-site/pages/404.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { NotFoundPage } from 'nextra-theme-docs'

# 404 - This page could not be found

<NotFoundPage />
5 changes: 5 additions & 0 deletions examples/swr-site/pages/500.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ServerSideErrorPage } from 'nextra-theme-docs'

# 500 - Internal Server Error

<ServerSideErrorPage />
57 changes: 57 additions & 0 deletions examples/swr-site/pages/docs/404-500.en-US.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 404 / 500 pages

Nextra support custom `404.mdx`/`500.mdx` pages.

## 404

To add `/404` page import `NotFoundPage`:

```mdx filename="pages/404.mdx"
import { NotFoundPage } from 'nextra-theme-docs'

# 404 - This page could not be found

<NotFoundPage />
```

[Click to try `/404` page.](/this-page-not-exist-trust-me)

## 500

To add `/500` page import `ServerSideErrorPage`:

```mdx filename="pages/500.mdx"
import { ServerSideErrorPage } from 'nextra-theme-docs'

# 500 - Internal Server Error

<ServerSideErrorPage />
```

[Click to try `/500` page.](/500)

## Customize Theme Config Options

Also, you can customize following options:

```ts
// ...
notFoundLink?: ReactNode | FC
notFoundLabels?: string
serverSideErrorLink?: ReactNode | FC
serverSideErrorLabels?: string
```

## Customize Layout

```json filename="meta.json"
"404": {
"type": "page"
},
"500": {
"type":"page",
"theme": {
"layout": "full"
}
}
```
3 changes: 2 additions & 1 deletion examples/swr-site/pages/docs/meta.en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
"type": "page",
"newWindow": true
},
"scroll-with-dynamic-height": "Scroll With Dynamic Height"
"scroll-with-dynamic-height": "Scroll With Dynamic Height",
"404-500": "404/500 Custom Error Pages"
}
9 changes: 9 additions & 0 deletions examples/swr-site/pages/meta.en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,14 @@
"href": "https://github.com/shuding/nextra",
"type": "page",
"newWindow": true
},
"404": {
"type": "page"
},
"500": {
"type":"page",
"theme": {
"layout": "full"
}
}
}