Skip to content

Commit 8932678

Browse files
committed
Additional logging around 404 detection and redirects
1 parent b5134e1 commit 8932678

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

.vitepress/theme/Layout.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,31 @@ watch(
2121
() => page.value.isNotFound,
2222
(isNotFound) => {
2323
if (!isNotFound || !inBrowser) return
24+
25+
console.log('[Layout 404] Checking redirects for:', window.location.pathname)
2426
const redirect = redirects.find(([from]) => window.location.pathname.startsWith(from))
25-
if (!redirect) return
27+
28+
if (!redirect) {
29+
console.log('[Layout 404] No redirect found for:', window.location.pathname)
30+
return
31+
}
32+
2633
const newPath = redirect[1] + window.location.pathname.slice(redirect[0].length)
2734
const search = window.location.search
2835
const hash = window.location.hash
29-
go(newPath + search + hash)
36+
const fullNewUrl = newPath + search + hash
37+
38+
console.log('[Layout 404] Redirect found:', {
39+
from: redirect[0],
40+
to: redirect[1],
41+
originalPath: window.location.pathname,
42+
newPath,
43+
search,
44+
hash,
45+
fullNewUrl
46+
})
47+
48+
go(fullNewUrl)
3049
},
3150
{ immediate: true }
3251
)

0 commit comments

Comments
 (0)