Skip to content

Commit 06ad0d8

Browse files
committed
refactor 404 page data
1 parent 28eaa3b commit 06ad0d8

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/client/app/router.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,19 @@ export const RouterSymbol: InjectionKey<Router> = Symbol()
2121
// matter and is only passed to support same-host hrefs.
2222
const fakeHost = `http://a.com`
2323

24+
const notFoundPageData: PageData = {
25+
relativePath: '',
26+
title: '404',
27+
description: 'Not Found',
28+
headers: [],
29+
frontmatter: {},
30+
lastUpdated: 0
31+
}
32+
2433
const getDefaultRoute = (): Route => ({
2534
path: '/',
2635
component: null,
27-
// this will be set upon initial page load, which is before
28-
// the app is mounted, so it's guaranteed to be available in
29-
// components. We just need enough data for 404 pages to render.
30-
data: { frontmatter: {} } as any
36+
data: notFoundPageData
3137
})
3238

3339
interface PageModule {
@@ -123,15 +129,7 @@ export function createRouter(
123129
latestPendingPath = null
124130
route.path = pendingPath
125131
route.component = fallbackComponent ? markRaw(fallbackComponent) : null
126-
// reset page data
127-
route.data = {
128-
relativePath: '',
129-
title: '404',
130-
description: 'Not Found',
131-
headers: [],
132-
frontmatter: {},
133-
lastUpdated: 0
134-
}
132+
route.data = notFoundPageData
135133
}
136134
}
137135
}

0 commit comments

Comments
 (0)