Skip to content

Commit 28ef0ea

Browse files
authoredSep 15, 2023
fix(client): router in invalid state after 404 (#2972)
1 parent 98679c9 commit 28ef0ea

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed
 

‎src/client/app/index.ts

+13-10
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,28 @@ function newRouter(): Router {
121121

122122
return createRouter((path) => {
123123
let pageFilePath = pathToFile(path)
124+
let pageModule = null
124125

125-
if (!pageFilePath) return null
126+
if (pageFilePath) {
127+
if (isInitialPageLoad) {
128+
initialPath = pageFilePath
129+
}
126130

127-
if (isInitialPageLoad) {
128-
initialPath = pageFilePath
129-
}
131+
// use lean build if this is the initial page load or navigating back
132+
// to the initial loaded path (the static vnodes already adopted the
133+
// static content on that load so no need to re-fetch the page)
134+
if (isInitialPageLoad || initialPath === pageFilePath) {
135+
pageFilePath = pageFilePath.replace(/\.js$/, '.lean.js')
136+
}
130137

131-
// use lean build if this is the initial page load or navigating back
132-
// to the initial loaded path (the static vnodes already adopted the
133-
// static content on that load so no need to re-fetch the page)
134-
if (isInitialPageLoad || initialPath === pageFilePath) {
135-
pageFilePath = pageFilePath.replace(/\.js$/, '.lean.js')
138+
pageModule = import(/*@vite-ignore*/ pageFilePath)
136139
}
137140

138141
if (inBrowser) {
139142
isInitialPageLoad = false
140143
}
141144

142-
return import(/*@vite-ignore*/ pageFilePath)
145+
return pageModule
143146
}, Theme.NotFound)
144147
}
145148

‎src/client/theme-default/NotFound.vue

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ onMounted(() => {
3737
class="link"
3838
:href="withBase(root)"
3939
:aria-label="theme.notFound?.linkLabel ?? 'go to home'"
40-
target="_self"
4140
>
4241
{{ theme.notFound?.linkText ?? 'Take me home' }}
4342
</a>

0 commit comments

Comments
 (0)
Please sign in to comment.