From f1b4e03a0988efcf7e46e2522020402a2d1abf20 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Fri, 3 May 2024 01:07:43 +0530 Subject: [PATCH] fix: render 404 page completely on client --- src/client/app/router.ts | 8 ++- src/client/theme-default/NotFound.vue | 50 +++++-------------- src/client/theme-default/composables/langs.ts | 9 +--- src/node/build/render.ts | 2 +- src/shared/shared.ts | 2 +- 5 files changed, 24 insertions(+), 47 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index e51b7f80..035c416a 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -156,7 +156,13 @@ export function createRouter( latestPendingPath = null route.path = inBrowser ? pendingPath : withBase(pendingPath) route.component = fallbackComponent ? markRaw(fallbackComponent) : null - route.data = notFoundPageData + const relativePath = inBrowser + ? pendingPath + .replace(/(^|\/)$/, '$1index') + .replace(/(\.html)?$/, '.md') + .replace(/^\//, '') + : '404.md' + route.data = { ...notFoundPageData, relativePath } } } } diff --git a/src/client/theme-default/NotFound.vue b/src/client/theme-default/NotFound.vue index 9ed917de..b9665142 100644 --- a/src/client/theme-default/NotFound.vue +++ b/src/client/theme-default/NotFound.vue @@ -1,55 +1,31 @@