fix(vue): missing unhead context (#3589)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Harlan Wilton
2025-03-18 01:09:02 +11:00
committed by GitHub
parent 6588ae8669
commit 0897e9ef05
3 changed files with 11 additions and 9 deletions

View File

@@ -3,6 +3,11 @@ import type { Plugin } from 'vue'
export default {
install(app) {
// check for existing head instance to avoid replacement
// bit hacky but we can't use injectHead() here
if (app._context.provides.usehead) {
return
}
const head = createHead()
app.use(head)
}

View File

@@ -61,7 +61,6 @@ export const useState = <T>(key: string, init: () => T): Ref<T> => {
export function useNuxtApp() {
return {
isHydrating: true,
isVue: true,
payload: { serverRendered: false }
}
}
@@ -69,7 +68,7 @@ export function useNuxtApp() {
export function defineNuxtPlugin(plugin: (nuxtApp: NuxtApp) => void) {
return {
install(app) {
plugin({ vueApp: app } as NuxtApp)
app.runWithContext(() => plugin({ vueApp: app } as NuxtApp))
}
} satisfies VuePlugin
}