chore: refine usePageSeo composable with stricter og:type handling
- Added explicit `OgType` types for better Open Graph compatibility. - Introduced default `og:type` fallback to `website`. - Replaced ad-hoc type handling with `computed` property. - Disabled ESLint in `auto-imports.d.ts` for consistent linting.
This commit is contained in:
@@ -14,12 +14,26 @@ import {
|
||||
SITE_URL,
|
||||
} from '@/config/site'
|
||||
|
||||
type OgType =
|
||||
| 'website'
|
||||
| 'article'
|
||||
| 'book'
|
||||
| 'profile'
|
||||
| 'music.song'
|
||||
| 'music.album'
|
||||
| 'music.playlist'
|
||||
| 'music.radio_status'
|
||||
| 'video.movie'
|
||||
| 'video.episode'
|
||||
| 'video.tv_show'
|
||||
| 'video.other'
|
||||
|
||||
interface UsePageSeoOptions {
|
||||
readonly title?: MaybeRefOrGetter<string | null | undefined>
|
||||
readonly description?: MaybeRefOrGetter<string | null | undefined>
|
||||
readonly image?: MaybeRefOrGetter<string | null | undefined>
|
||||
readonly imageAlt?: MaybeRefOrGetter<string | null | undefined>
|
||||
readonly type?: MaybeRefOrGetter<string | null | undefined>
|
||||
readonly type?: MaybeRefOrGetter<OgType | null | undefined>
|
||||
readonly canonical?: MaybeRefOrGetter<string | null | undefined>
|
||||
readonly structuredData?: MaybeRefOrGetter<
|
||||
| Record<string, unknown>
|
||||
@@ -62,6 +76,10 @@ export function usePageSeo(options: UsePageSeoOptions) {
|
||||
const robots = computed(() =>
|
||||
toValue(options?.noindex) ? 'noindex, nofollow' : 'index, follow'
|
||||
)
|
||||
const ogType = computed<OgType>(() => {
|
||||
const type = toValue(options?.type)
|
||||
return type ?? 'website'
|
||||
})
|
||||
|
||||
useSeoMeta({
|
||||
title: () => title.value,
|
||||
@@ -69,7 +87,7 @@ export function usePageSeo(options: UsePageSeoOptions) {
|
||||
robots: () => robots.value,
|
||||
ogTitle: () => title.value,
|
||||
ogDescription: () => description.value,
|
||||
ogType: () => toValue(options?.type) || 'website',
|
||||
ogType: () => ogType.value,
|
||||
ogUrl: () => canonical.value,
|
||||
ogImage: () => image.value,
|
||||
ogImageAlt: () => imageAlt.value,
|
||||
|
||||
Reference in New Issue
Block a user