Skip to content

Commit

Permalink
fix(client): router in invalid state after 404 (#2972)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Sep 15, 2023
1 parent 98679c9 commit 28ef0ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
23 changes: 13 additions & 10 deletions src/client/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
1 change: 0 additions & 1 deletion src/client/theme-default/NotFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 28ef0ea

Please sign in to comment.