Skip to content

Commit

Permalink
fix: apply subsequent meta changes (nuxt#3271)
Browse files Browse the repository at this point in the history
  • Loading branch information
Diizzayy authored Feb 16, 2022
1 parent 77aeaa3 commit ad52b79
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/nuxt3/src/meta/runtime/lib/vueuse-head.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,29 @@ export default defineNuxtPlugin((nuxtApp) => {
const head = createHead()

nuxtApp.vueApp.use(head)
nuxtApp.hooks.hookOnce('app:mounted', () => { watchEffect(() => head.updateDOM()) })

let headReady = false
nuxtApp.hooks.hookOnce('app:mounted', () => {
watchEffect(() => { head.updateDOM() })
headReady = true
})

nuxtApp._useMeta = (meta: MetaObject) => {
const headObj = ref(meta as any)
head.addHeadObjs(headObj)

if (process.server) { return }

if (headReady) {
watchEffect(() => { head.updateDOM() })
}

const vm = getCurrentInstance()
if (!vm) { return }

onBeforeUnmount(() => {
head.removeHeadObjs(headObj)
head.updateDOM()
})
}

Expand Down

0 comments on commit ad52b79

Please sign in to comment.