From 0af01668c1d83ec0f06da5d43b3a673855cae7ee Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 17 Jan 2022 20:52:24 +0000 Subject: [PATCH] feat(nuxt3): pass `nuxtApp` to `head()` (#2765) --- packages/nuxt3/src/meta/runtime/plugin.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/nuxt3/src/meta/runtime/plugin.ts b/packages/nuxt3/src/meta/runtime/plugin.ts index a28d6b7f2e..7d501e1312 100644 --- a/packages/nuxt3/src/meta/runtime/plugin.ts +++ b/packages/nuxt3/src/meta/runtime/plugin.ts @@ -1,4 +1,4 @@ -import { getCurrentInstance } from 'vue' +import { computed, getCurrentInstance } from 'vue' import * as Components from './components' import { useMeta } from './composables' import { defineNuxtPlugin } from '#app' @@ -19,7 +19,11 @@ export default defineNuxtPlugin((nuxtApp) => { const options = instance?.type || /* nuxt2 */ instance?.proxy?.$options if (!options || !('head' in options)) { return } - useMeta(options.head) + const source = typeof options.head === 'function' + ? computed(() => options.head(nuxtApp)) + : options.head + + useMeta(source) } })