diff --git a/packages/nuxt/src/head/module.ts b/packages/nuxt/src/head/module.ts index f366bb4aea..a8dcccbdae 100644 --- a/packages/nuxt/src/head/module.ts +++ b/packages/nuxt/src/head/module.ts @@ -1,5 +1,5 @@ import { resolve } from 'pathe' -import { addPlugin, addTemplate, defineNuxtModule, isNuxt3 } from '@nuxt/kit' +import { addPlugin, addTemplate, defineNuxtModule } from '@nuxt/kit' import defu from 'defu' import { distDir } from '../dirs' import type { MetaObject } from './runtime' @@ -31,7 +31,7 @@ export default defineNuxtModule({ // Add global meta configuration addTemplate({ filename: 'meta.config.mjs', - getContents: () => 'export default ' + JSON.stringify({ globalMeta, mixinKey: isNuxt3() ? 'created' : 'setup' }) + getContents: () => 'export default ' + JSON.stringify({ globalMeta }) }) // Add generic plugin diff --git a/packages/nuxt/src/head/runtime/plugin.ts b/packages/nuxt/src/head/runtime/plugin.ts index d3b3c4291a..4cad862bf1 100644 --- a/packages/nuxt/src/head/runtime/plugin.ts +++ b/packages/nuxt/src/head/runtime/plugin.ts @@ -1,4 +1,4 @@ -import { computed, getCurrentInstance } from 'vue' +import { computed, getCurrentInstance, markRaw } from 'vue' import * as Components from './components' import { useHead } from './composables' import { defineNuxtPlugin, useNuxtApp } from '#app' @@ -11,11 +11,11 @@ declare module 'vue' { } const metaMixin = { - [metaConfig.mixinKey] () { + created () { const instance = getCurrentInstance() if (!instance) { return } - const options = instance.type || /* nuxt2 */ instance.proxy?.$options + const options = instance.type if (!options || !('head' in options)) { return } const nuxtApp = useNuxtApp() @@ -28,7 +28,7 @@ const metaMixin = { } export default defineNuxtPlugin((nuxtApp) => { - useHead(metaConfig.globalMeta) + useHead(markRaw(metaConfig.globalMeta)) nuxtApp.vueApp.mixin(metaMixin)