import { computed } from 'vue'
import { useSeoMeta } from '@unhead/vue'
import { useStrapiGlobal } from '@/composables/useStrapi'

export default (pageSeo) => {
    const { data: globalData } = useStrapiGlobal()

    const globalSeo = computed(() => globalData?.value?.seo)

    const title = computed(() => {
        return pageSeo?.title || globalSeo.value?.title || ''
    })
    const description = computed(() => {
        return pageSeo?.description || globalSeo.value?.description || ''
    })
    const image = computed(() => {
        return pageSeo?.image || globalSeo.value?.image
    })

    useSeoMeta({
        title: title.value,
        description: description.value,
    })
}
