2022-11-28 14:55:51 +01:00
|
|
|
import type { ActiveHeadEntry, HeadEntryOptions, UseHeadInput } from '@vueuse/head'
|
|
|
|
import type { HeadAugmentations } from '@nuxt/schema'
|
2022-11-29 23:49:25 +01:00
|
|
|
import { useHead } from '#head'
|
2022-11-28 14:55:51 +01:00
|
|
|
|
2022-11-29 23:49:25 +01:00
|
|
|
// TODO: Workaround for Nuxt bug: https://github.com/elk-zone/elk/pull/199#issuecomment-1329771961
|
|
|
|
export function useHeadFixed<T extends HeadAugmentations>(input: UseHeadInput<T>, options?: HeadEntryOptions): ActiveHeadEntry<UseHeadInput<T>> | void {
|
2022-11-28 14:55:51 +01:00
|
|
|
const deactivated = useDeactivated()
|
2022-11-29 23:49:25 +01:00
|
|
|
return useHead(() => {
|
2022-11-28 14:55:51 +01:00
|
|
|
if (deactivated.value)
|
|
|
|
return {}
|
|
|
|
return resolveUnref(input)
|
|
|
|
}, options)
|
|
|
|
}
|