Skip to content

Commit

Permalink
fix(asyncData): $nuxt undefined fix
Browse files Browse the repository at this point in the history
fixes the `$nuxt undefined` error for newer versions of nuxt

Closes #5
  • Loading branch information
nickfrosty committed Dec 12, 2021
1 parent 5b572a1 commit cf3e879
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions package/lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ export default function (ctx, inject) {
ctx.app.context.app.head = ctx.app.head
}

if (Vue.prototype && Vue.prototype.$meta) { // Vue-meta is enabled
if (this.$nuxt && this.$nuxt.$options && this.$nuxt.$options.head) {
this.$nuxt.$options.head = ctx.app.head
} else if (Vue.prototype.$nuxt && Vue.prototype.$nuxt.$options && Vue.prototype.$nuxt.$options.head) {
Vue.prototype.$nuxt.$options.head = ctx.app.head
try {
if (Vue.prototype && Vue.prototype.$meta) { // Vue-meta is enabled
if (this.$nuxt && this.$nuxt.$options && this.$nuxt.$options.head) {
this.$nuxt.$options.head = ctx.app.head
} else if (Vue.prototype.$nuxt && Vue.prototype.$nuxt.$options && Vue.prototype.$nuxt.$options.head) {
Vue.prototype.$nuxt.$options.head = ctx.app.head
}
}
}
catch ( err ){
// unable to parse vue head
}

deb('HEAD:', ctx.app.head)
return ctx.app.head
Expand Down

0 comments on commit cf3e879

Please # to comment.