fix: resolve page hash case-insenstively, close #202 (#203)

pull/207/head
Anthony Fu 4 years ago committed by GitHub
parent d8bf3b2886
commit bac1ce2d01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -113,7 +113,7 @@ function shouldHotReload(payload: any): boolean {
if (inBrowser) {
const { app, router } = createApp()
// wait unitl page component is fetched before mounting
// wait until page component is fetched before mounting
router.go().then(() => {
app.mount('#app')
})

@ -23,7 +23,7 @@ const getDefaultRoute = (): Route => ({
path: '/',
component: null,
// this will be set upon initial page load, which is before
// the app is mounted, so it's guaranteed to be avaiable in
// the app is mounted, so it's guaranteed to be available in
// components
data: null as any
})

@ -17,7 +17,7 @@ export function pathToFile(path: string): string {
}
if (import.meta.env.DEV) {
// awlays force re-fetch content in dev
// always force re-fetch content in dev
pagePath += `.md?t=${Date.now()}`
} else {
// in production, each .md file is built into a .md.js file following
@ -28,7 +28,7 @@ export function pathToFile(path: string): string {
pagePath = pagePath.slice(base.length).replace(/\//g, '_') + '.md'
// client production build needs to account for page hash, which is
// injected directly in the page's html
const pageHash = __VP_HASH_MAP__[pagePath]
const pageHash = __VP_HASH_MAP__[pagePath.toLowerCase()]
pagePath = `${base}assets/${pagePath}.${pageHash}.js`
} else {
// ssr build uses much simpler name mapping

@ -29,7 +29,7 @@ export async function renderPage(
const pageServerJsFileName = pageName + '.js'
// for any initial page load, we only need the lean version of the page js
// since the static content is already on the page!
const pageHash = pageToHashMap[pageName]
const pageHash = pageToHashMap[pageName.toLowerCase()]
const pageClientJsFileName = `assets/${pageName}.${pageHash}.lean.js`
// resolve page data so we can render head tags

@ -122,7 +122,7 @@ export function createVitePressPlugin(
if (isPageChunk(chunk)) {
// record page -> hash relations
const hash = chunk.fileName.match(hashRE)![1]
pageToHashMap![chunk.name] = hash
pageToHashMap![chunk.name.toLowerCase()] = hash
// inject another chunk with the content stripped
bundle[name + '-lean'] = {

Loading…
Cancel
Save