nuxt初始化
This commit is contained in:
34
nuxt-web/composables/useSeo.ts
Normal file
34
nuxt-web/composables/useSeo.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
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
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user