refactor(nuxt)!: remove null handling for titleTemplate (#6487)

This commit is contained in:
Daniel Roe 2022-08-10 16:46:46 +01:00 committed by GitHub
parent cafd3938ed
commit 408febada4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 11 deletions

View File

@ -15,20 +15,10 @@ export default defineNuxtPlugin((nuxtApp) => {
headReady = true
})
const titleTemplate = ref<MetaObject['titleTemplate']>()
nuxtApp._useHead = (_meta: MetaObject | ComputedGetter<MetaObject>) => {
const meta = ref<MetaObject>(_meta)
if ('titleTemplate' in meta.value) {
titleTemplate.value = meta.value.titleTemplate
}
const headObj = computed(() => {
const overrides: MetaObject = { meta: [] }
// cast a null titleTemplate to an empty string so @vueuse/head ignores it
if (titleTemplate.value === null) {
overrides.titleTemplate = ''
}
if (meta.value.charset) {
overrides.meta!.push({ key: 'charset', charset: meta.value.charset })
}

View File

@ -27,7 +27,7 @@ const config = useRuntimeConfig()
// reset title template example
useHead({
titleTemplate: null
titleTemplate: ''
})
const foo = useFoo()