Skip to content

Commit 374ae43

Browse files
committed
fix(client): make page data hmr work as expected
1 parent a8c43c0 commit 374ae43

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/@vuepress/client/src/injections/pageData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const resolvePageData = async (routePath: string): Promise<PageData> => {
4141
if (import.meta.webpackHot || import.meta.hot) {
4242
// reuse vue HMR runtime
4343
__VUE_HMR_RUNTIME__.updatePageData = (data: PageData) => {
44+
pagesData.value[data.path] = () => Promise.resolve(data)
4445
if (data.key === pageData.value.key) {
4546
pageData.value = data
4647
}

packages/@vuepress/client/src/injections/pagesData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { readonly, ref } from 'vue'
1+
import { ref } from 'vue'
22
import type { Ref } from 'vue'
33
import type { PageData } from '@vuepress/shared'
44
import { pagesData as pagesDataRaw } from '@internal/pagesData'
55

66
export type PagesData = Record<string, () => Promise<PageData>>
77
export type PagesDataRef = Ref<PagesData>
88

9-
export const pagesData: PagesDataRef = ref(readonly(pagesDataRaw) as PagesData)
9+
export const pagesData: PagesDataRef = ref(pagesDataRaw)
1010

1111
export const usePagesData = (): PagesDataRef => {
1212
return pagesData

0 commit comments

Comments
 (0)