Skip to content

Commit

Permalink
fix: use head instance from plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux authored and benjamincanac committed Sep 7, 2023
1 parent f1ed007 commit 791804b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/plugins/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import colors from '#tailwind-config/theme/colors'

export default defineNuxtPlugin({
enforce: 'post',
setup () {
setup (nuxtApp) {
const appConfig = useAppConfig()
const head = nuxtApp.vueApp._context.provides.usehead

const root = computed(() => {
const primary: Record<string, string> | undefined = colors[appConfig.ui.primary]
Expand Down Expand Up @@ -32,7 +33,7 @@ export default defineNuxtPlugin({
appConfig.ui.gray = window.localStorage.getItem('nuxt-ui-gray') || appConfig.ui.gray
}
if (process.server) {
useHead({
head.push({
script: [
{
innerHTML: `
Expand Down
7 changes: 4 additions & 3 deletions src/runtime/plugins/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { hexToRgb } from '../utils'
import { defineNuxtPlugin, useHead, useAppConfig, useNuxtApp } from '#imports'
import colors from '#tailwind-config/theme/colors'

export default defineNuxtPlugin(() => {
export default defineNuxtPlugin((nuxtApp) => {
const appConfig = useAppConfig()
const nuxtApp = useNuxtApp()
const head = nuxtApp.vueApp._context.provides.usehead

const root = computed(() => {
const primary: Record<string, string> | undefined = colors[appConfig.ui.primary]
Expand Down Expand Up @@ -53,5 +53,6 @@ ${Object.entries(gray || colors.cool).map(([key, value]) => `--color-gray-${key}
}]
}

useHead(headData)
// Workaround for https://github.com/nuxt/nuxt/issues/22763
head.push(headData)
})

0 comments on commit 791804b

Please sign in to comment.