content icon indicating copy to clipboard operation
content copied to clipboard

Fallback to 404 page when not-found slot doesn't exist

Open kecrily opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe

When using <ContentDoc /> to render markdown, but neither the md file nor the not-found slot exists, a prompt asking to use the not-found slot is displayed. This makes user-defined 404 pages not used as expected at all.

Describe the solution you'd like

There is no not-found slot, but if the user has defined a 404 page, it will fall back to the 404 page first. Instead of directly showing a prompt asking the user to use the slot.

Describe alternatives you've considered

Additional context

kecrily avatar Sep 10 '22 16:09 kecrily

Do you by any chance have a catch-all route, such as pages/[...slug].vue? If so, that's what's causing the ~/error.vue to not be used, it takes precedence. In such a case, you could try and reorganize your catch-all route, for example do this instead:

pages/
--| about.vue
--| posts/
----| [slug].vue
----| index.vue
error.vue

cossssmin avatar Mar 29 '23 22:03 cossssmin

Do you by any chance have a catch-all route, such as pages/[...slug].vue? If so, that's what's causing the ~/error.vue to not be used, it takes precedence. In such a case, you could try and reorganize your catch-all route, for example do this instead:

pages/
--| about.vue
--| posts/
----| [slug].vue
----| index.vue
error.vue

That did the trick, thank you!

I'd love to add that to the docs... but where? Maybe: https://content.nuxtjs.org/api/components/content-doc#slots ?

PatrikBird avatar Sep 08 '23 10:09 PatrikBird

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Feb 07 '25 12:02 github-actions[bot]