web-infra-dev / rspress

🦀💨 A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.19k stars 108 forks source link

[Feature]: Generate 404.html by default when build #1171

Closed Timeless0911 closed 1 week ago

Timeless0911 commented 2 weeks ago

What problem does this feature solve?

We should generate 404.html by default in build process to let pageType: 404 and NotFoundLayout work in production by default.

Now we return 404 when generate site data, so we can visit 404 page in dev correctly

https://github.com/web-infra-dev/rspress/blob/150f770aaa3a02407af3ac3e25f0df36ddc4ac59/packages/core/src/runtime/App.tsx#L102-L117

but in production now we need to write a 404.mdx like below:

---
pageType: 404
---

import { NotFoundLayout } from "@theme"

<NotFoundLayout />

What does the proposed API look like?

.
├── index.html
├── 404.html
└── static
    ├── css
    ├── js
    └── search_index.xxxxxx.json