Files
vue-seo-layer/app/plugins/seo-head.ts

15 lines
685 B
TypeScript

// One head entry for the whole app, following the resolve answer of the
// current page. tagPriority 'critical' makes its tags win over the same
// tags a page or another module sets (unhead keeps the lower weight), so
// editor values from the SEO plugin override the content defaults; a value
// the answer lacks leaves the page's own tag in place.
import { seoHeadInput } from '../utils/seo.ts'
export default defineNuxtPlugin(() => {
const config = useRuntimeConfig()
if ((config.public.seo as { enabled?: boolean } | undefined)?.enabled === false) return
const answer = useSeoAnswer()
useHead(computed(() => seoHeadInput(answer.value)), { tagPriority: 'critical' })
})