1
0
Files
ag-index/nuxt-web/composables/useSeo.ts
2026-04-20 09:45:20 +08:00

35 lines
780 B
TypeScript

type SeoInput = {
title: string
description?: string
keywords?: string
ogImage?: string
canonicalPath?: string
}
export function useSeo(input: SeoInput) {
const siteUrl = 'https://example.com'
const fullTitle = `${input.title} - 烟台岸基网络科技有限公司`
const canonical = input.canonicalPath ? `${siteUrl}${input.canonicalPath}` : undefined
useSeoMeta({
title: fullTitle,
description: input.description,
keywords: input.keywords,
ogTitle: fullTitle,
ogDescription: input.description,
ogImage: input.ogImage,
twitterCard: input.ogImage ? 'summary_large_image' : 'summary'
})
if (canonical) {
useHead({
link: [
{
rel: 'canonical',
href: canonical
}
]
})
}
}