Skip to content

Commit b2a7a02

Browse files
authored
refactor(theme): use metaInfo() and nuxt() instead of hacking $options (#3488)
fixes #3482
1 parent 7d427c7 commit b2a7a02

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/components/VApp/mixins/app-theme.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,38 @@ export default {
4242
}
4343

4444
return css
45+
},
46+
vueMeta () {
47+
return {
48+
style: [{
49+
cssText: this.generatedStyles,
50+
type: 'text/css',
51+
id: 'vuetify-theme-stylesheet'
52+
}]
53+
}
4554
}
4655
},
4756

57+
// Regular vue-meta
58+
metaInfo () {
59+
return this.vueMeta
60+
},
61+
62+
// Nuxt
63+
head () {
64+
return this.vueMeta
65+
},
66+
4867
watch: {
4968
generatedStyles () {
5069
!this.meta && this.applyTheme()
5170
}
5271
},
5372

54-
beforeCreate () {
55-
if (this.$meta) {
56-
// Vue-meta
57-
const keyName = this.$nuxt ? 'head' : 'metaInfo'
58-
this.$options[keyName] = () => ({
59-
style: [{
60-
cssText: this.generatedStyles,
61-
type: 'text/css',
62-
id: 'vuetify-theme-stylesheet'
63-
}]
64-
})
65-
}
66-
},
67-
6873
created () {
6974
if (this.$meta) {
7075
// Vue-meta
71-
// Handled by beforeCreate hook
76+
// Handled by metaInfo()/nuxt()
7277
} else if (typeof document === 'undefined' && this.$ssrContext) {
7378
// SSR
7479
this.$ssrContext.head = this.$ssrContext.head || ''

0 commit comments

Comments
 (0)