From 049f61e62869248b7f1e1fc924072601a3a568bc Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 9 Jan 2021 00:12:54 +0800 Subject: [PATCH 1/4] fix: resolve page hash case-insenstively, close #202 --- src/client/app/index.ts | 2 +- src/client/app/router.ts | 2 +- src/node/build/render.ts | 2 +- src/node/plugin.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/app/index.ts b/src/client/app/index.ts index f791f250245e..d878a84fe712 100644 --- a/src/client/app/index.ts +++ b/src/client/app/index.ts @@ -113,7 +113,7 @@ function shouldHotReload(payload: any): boolean { if (inBrowser) { const { app, router } = createApp() - // wait unitl page component is fetched before mounting + // wait util page component is fetched before mounting router.go().then(() => { app.mount('#app') }) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 4c314ce3ac49..6a99e132ea39 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -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 }) diff --git a/src/node/build/render.ts b/src/node/build/render.ts index 4c2d54c84737..896891661604 100644 --- a/src/node/build/render.ts +++ b/src/node/build/render.ts @@ -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 diff --git a/src/node/plugin.ts b/src/node/plugin.ts index 53baae8a8785..29449449b865 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -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'] = { From aec02a38081f4f34cade8134d2ff73fa27a5fa3e Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 9 Jan 2021 00:14:51 +0800 Subject: [PATCH 2/4] chore: typo --- src/client/app/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/app/index.ts b/src/client/app/index.ts index d878a84fe712..5eb688e3bbc1 100644 --- a/src/client/app/index.ts +++ b/src/client/app/index.ts @@ -113,7 +113,7 @@ function shouldHotReload(payload: any): boolean { if (inBrowser) { const { app, router } = createApp() - // wait util page component is fetched before mounting + // wait until page component is fetched before mounting router.go().then(() => { app.mount('#app') }) From 0a992da390fa17704ba26ff28adbe73844f44f6b Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 9 Jan 2021 00:38:55 +0800 Subject: [PATCH 3/4] chore: fix --- src/client/app/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/app/utils.ts b/src/client/app/utils.ts index 0eee7e113806..45d723041c50 100644 --- a/src/client/app/utils.ts +++ b/src/client/app/utils.ts @@ -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 From 8bce7c18d6fd2fc576bb0f160add38acec87a8f5 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sat, 9 Jan 2021 00:39:12 +0800 Subject: [PATCH 4/4] chore: typo --- src/client/app/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/app/utils.ts b/src/client/app/utils.ts index 45d723041c50..26383bf5f80c 100644 --- a/src/client/app/utils.ts +++ b/src/client/app/utils.ts @@ -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