Skip to content

Commit 3174f5a

Browse files
committed
fix(client): only watch route path to update head
1 parent 028c20b commit 3174f5a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { onMounted, ref, useSSRContext, watch } from 'vue'
2+
import { useRoute } from 'vue-router'
23
import { isPlainObject, isString } from '@vuepress/shared'
34
import type { HeadConfig, VuepressSSRContext } from '@vuepress/shared'
45
import { usePageHead } from './pageHead'
@@ -70,6 +71,7 @@ export const createHeadTag = ([
7071
* This composable function should be used only once in the root app
7172
*/
7273
export const useUpdateHead = (): void => {
74+
const route = useRoute()
7375
const head = usePageHead()
7476
const lang = usePageLang()
7577

@@ -118,6 +120,9 @@ export const useUpdateHead = (): void => {
118120
onMounted(() => {
119121
loadHead()
120122
updateHead()
121-
watch([head, lang], () => updateHead())
123+
watch(
124+
() => route.path,
125+
() => updateHead()
126+
)
122127
})
123128
}

0 commit comments

Comments
 (0)