fix(client): router in invalid state after 404 (#2972)

pull/2973/head
Divyansh Singh 1 year ago committed by GitHub
parent 98679c9e82
commit 28ef0ea6f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -121,25 +121,28 @@ function newRouter(): Router {
return createRouter((path) => {
let pageFilePath = pathToFile(path)
let pageModule = null
if (!pageFilePath) return null
if (pageFilePath) {
if (isInitialPageLoad) {
initialPath = pageFilePath
}
if (isInitialPageLoad) {
initialPath = pageFilePath
}
// use lean build if this is the initial page load or navigating back
// to the initial loaded path (the static vnodes already adopted the
// static content on that load so no need to re-fetch the page)
if (isInitialPageLoad || initialPath === pageFilePath) {
pageFilePath = pageFilePath.replace(/\.js$/, '.lean.js')
}
// use lean build if this is the initial page load or navigating back
// to the initial loaded path (the static vnodes already adopted the
// static content on that load so no need to re-fetch the page)
if (isInitialPageLoad || initialPath === pageFilePath) {
pageFilePath = pageFilePath.replace(/\.js$/, '.lean.js')
pageModule = import(/*@vite-ignore*/ pageFilePath)
}
if (inBrowser) {
isInitialPageLoad = false
}
return import(/*@vite-ignore*/ pageFilePath)
return pageModule
}, Theme.NotFound)
}

@ -37,7 +37,6 @@ onMounted(() => {
class="link"
:href="withBase(root)"
:aria-label="theme.notFound?.linkLabel ?? 'go to home'"
target="_self"
>
{{ theme.notFound?.linkText ?? 'Take me home' }}
</a>

Loading…
Cancel
Save