Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat(bridge): use useMeta in bridge projects #664

Merged
merged 14 commits into from
Oct 6, 2021
Merged
2 changes: 1 addition & 1 deletion packages/bridge/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default defineNuxtModule({
}
})
}
if (opts.meta !== false) {
if (opts.meta !== false && opts.capi) {
await setupMeta({ enable: opts.meta })
}
}
Expand Down
7 changes: 7 additions & 0 deletions packages/bridge/src/runtime/capi.plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@ import VueCompositionAPI from '@vue/composition-api'

Vue.use(VueCompositionAPI.default || VueCompositionAPI)

Vue.mixin({
setup () {
const vm = getCurrentInstance()
vm.type = vm.type || vm.proxy?.$options
}
})

export default function () {}
5 changes: 2 additions & 3 deletions packages/nuxt3/src/meta/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ export default defineNuxtPlugin((nuxt) => {
useMeta(metaConfig.globalMeta)

nuxt.app.mixin({
[metaConfig.mixinKey] () {
const instance = getCurrentInstance()
const options = instance?.type || /* nuxt2 */ instance?.proxy?.$options
setup () {
const options = getCurrentInstance()?.type
if (!options || !('head' in options)) { return }

useMeta(options.head)
Expand Down