refactor: share notFoundPageData

pull/740/head
Divyansh Singh 3 years ago
parent 9aed4d1ea9
commit c4e8df5cc7

@ -1,6 +1,6 @@
import { reactive, inject, markRaw, nextTick, readonly } from 'vue'
import type { Component, InjectionKey } from 'vue'
import { PageData } from '../shared'
import { notFoundPageData, PageData } from '../shared'
import { inBrowser, withBase } from './utils'
import { siteDataRef } from './data'
@ -21,15 +21,6 @@ export const RouterSymbol: InjectionKey<Router> = Symbol()
// matter and is only passed to support same-host hrefs.
const fakeHost = `http://a.com`
const notFoundPageData: PageData = {
relativePath: '',
title: '404',
description: 'Not Found',
headers: [],
frontmatter: {},
lastUpdated: 0
}
const getDefaultRoute = (): Route => ({
path: '/',
component: null,

@ -5,7 +5,7 @@ import { pathToFileURL } from 'url'
import escape from 'escape-html'
import { normalizePath, transformWithEsbuild } from 'vite'
import { RollupOutput, OutputChunk, OutputAsset } from 'rollup'
import { HeadConfig, createTitle, PageData } from '../shared'
import { HeadConfig, createTitle, PageData, notFoundPageData } from '../shared'
import { slash } from '../utils/slash'
import { SiteConfig, resolveSiteDataByRoute } from '../config'
@ -64,14 +64,7 @@ export async function renderPage(
} catch (e) {
if (page === '404.md') {
hasCustom404 = false
pageData = {
relativePath: '',
title: '404',
description: 'Not Found',
headers: [],
frontmatter: {},
lastUpdated: 0
}
pageData = notFoundPageData
} else throw e
}

@ -126,3 +126,12 @@ function cleanRoute(siteData: SiteData, route: string): string {
return route.slice(baseWithoutSuffix.length)
}
export const notFoundPageData: PageData = {
relativePath: '',
title: '404',
description: 'Not Found',
headers: [],
frontmatter: {},
lastUpdated: 0
}

Loading…
Cancel
Save