refactor 404 page data

pull/552/head
Evan You 3 years ago
parent 28eaa3b04a
commit 06ad0d8386

@ -21,13 +21,19 @@ export const RouterSymbol: InjectionKey<Router> = Symbol()
// matter and is only passed to support same-host hrefs. // matter and is only passed to support same-host hrefs.
const fakeHost = `http://a.com` const fakeHost = `http://a.com`
const notFoundPageData: PageData = {
relativePath: '',
title: '404',
description: 'Not Found',
headers: [],
frontmatter: {},
lastUpdated: 0
}
const getDefaultRoute = (): Route => ({ const getDefaultRoute = (): Route => ({
path: '/', path: '/',
component: null, component: null,
// this will be set upon initial page load, which is before data: notFoundPageData
// the app is mounted, so it's guaranteed to be available in
// components. We just need enough data for 404 pages to render.
data: { frontmatter: {} } as any
}) })
interface PageModule { interface PageModule {
@ -123,15 +129,7 @@ export function createRouter(
latestPendingPath = null latestPendingPath = null
route.path = pendingPath route.path = pendingPath
route.component = fallbackComponent ? markRaw(fallbackComponent) : null route.component = fallbackComponent ? markRaw(fallbackComponent) : null
// reset page data route.data = notFoundPageData
route.data = {
relativePath: '',
title: '404',
description: 'Not Found',
headers: [],
frontmatter: {},
lastUpdated: 0
}
} }
} }
} }

Loading…
Cancel
Save