Closed
Description
Feature request
What problem does this feature solve?
After using vuepress a lot, I stumbled over two problems with the current handling of missing routes.
- Instead of delivering a page defined at the site level, like the content of a
/404.md
file, the whole error pages is defined byNotFound.vue
, at the theme level. This couples the layout with the content and changes he behaviour compared to normal pages usingLayout.vue
, where<Content>
is available. Additional information like a list of site specific, helpful links or messages can therefore only be added overconfig.js
or similar places, reducing the ease of use, compared to markdown files. - If the server responses to missing route with the content of an error page itself, like
/404.html
, vuepress immediately changes the page's content to the one inNotFound.vue
, hiding the previously content after a fleeting glimpse.
I am also not sure if the latter one was intended, as /404.md
pages are especially handled by vuepress (see the following code snippet from https://github.com/vuejs/vuepress/blob/master/lib/build.js).
// if the user does not have a custom 404.md, generate the theme's default
if (!options.siteData.pages.some(p => p.path === '/404.html')) {
await renderPage({ path: '/404.html' })
}
However, it is only rendered if example.org/404.html
is directly accessed, but hidden if only its content is delivered for routes like example.org/missing.html
. Which is the fixed behaviour of AWS S3 and CloudFront, delivering only the content of an error page, without causing an additional redirect.
What does the proposed API look like?
How should this be implemented in your opinion?
- Making the content of a site's
/404.md
accessible to the theme'sNotFound.vue
via<Content>
. - Generating
/404.html
based onNotFound.vue
and falling back toLayout.vue
if the former is missing.^ - Serving the component defined by
/404.md
instead ofNotFound.vue
forpath: '*'
.
^On a site note, this also makes it easier to generate error pages which retain the overall layout, including the header, navigation, ...
Are you willing to work on this yourself?**
Sure 👍