feat(nuxt3): pass nuxtApp to head() (#2765)

This commit is contained in:
Daniel Roe 2022-01-17 20:52:24 +00:00 committed by GitHub
parent e9d73f572f
commit 0af01668c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { getCurrentInstance } from 'vue' import { computed, getCurrentInstance } from 'vue'
import * as Components from './components' import * as Components from './components'
import { useMeta } from './composables' import { useMeta } from './composables'
import { defineNuxtPlugin } from '#app' import { defineNuxtPlugin } from '#app'
@ -19,7 +19,11 @@ export default defineNuxtPlugin((nuxtApp) => {
const options = instance?.type || /* nuxt2 */ instance?.proxy?.$options const options = instance?.type || /* nuxt2 */ instance?.proxy?.$options
if (!options || !('head' in options)) { return } if (!options || !('head' in options)) { return }
useMeta(options.head) const source = typeof options.head === 'function'
? computed(() => options.head(nuxtApp))
: options.head
useMeta(source)
} }
}) })