mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 11:20:36 +01:00
fix: use head instance from plugin
This commit is contained in:
committed by
Benjamin Canac
parent
f1ed0076e5
commit
791804b2fb
@@ -3,8 +3,9 @@ import colors from '#tailwind-config/theme/colors'
|
|||||||
|
|
||||||
export default defineNuxtPlugin({
|
export default defineNuxtPlugin({
|
||||||
enforce: 'post',
|
enforce: 'post',
|
||||||
setup () {
|
setup (nuxtApp) {
|
||||||
const appConfig = useAppConfig()
|
const appConfig = useAppConfig()
|
||||||
|
const head = nuxtApp.vueApp._context.provides.usehead
|
||||||
|
|
||||||
const root = computed(() => {
|
const root = computed(() => {
|
||||||
const primary: Record<string, string> | undefined = colors[appConfig.ui.primary]
|
const primary: Record<string, string> | undefined = colors[appConfig.ui.primary]
|
||||||
@@ -32,7 +33,7 @@ export default defineNuxtPlugin({
|
|||||||
appConfig.ui.gray = window.localStorage.getItem('nuxt-ui-gray') || appConfig.ui.gray
|
appConfig.ui.gray = window.localStorage.getItem('nuxt-ui-gray') || appConfig.ui.gray
|
||||||
}
|
}
|
||||||
if (process.server) {
|
if (process.server) {
|
||||||
useHead({
|
head.push({
|
||||||
script: [
|
script: [
|
||||||
{
|
{
|
||||||
innerHTML: `
|
innerHTML: `
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { hexToRgb } from '../utils'
|
|||||||
import { defineNuxtPlugin, useHead, useAppConfig, useNuxtApp } from '#imports'
|
import { defineNuxtPlugin, useHead, useAppConfig, useNuxtApp } from '#imports'
|
||||||
import colors from '#tailwind-config/theme/colors'
|
import colors from '#tailwind-config/theme/colors'
|
||||||
|
|
||||||
export default defineNuxtPlugin(() => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
const appConfig = useAppConfig()
|
const appConfig = useAppConfig()
|
||||||
const nuxtApp = useNuxtApp()
|
const head = nuxtApp.vueApp._context.provides.usehead
|
||||||
|
|
||||||
const root = computed(() => {
|
const root = computed(() => {
|
||||||
const primary: Record<string, string> | undefined = colors[appConfig.ui.primary]
|
const primary: Record<string, string> | undefined = colors[appConfig.ui.primary]
|
||||||
@@ -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)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user