게시물 SEO 설정 추가
This commit is contained in:
@@ -16,6 +16,44 @@ if (!post.value) {
|
||||
}
|
||||
|
||||
const postTag = computed(() => post.value.tags?.[0]?.toUpperCase() || 'POST')
|
||||
const config = useRuntimeConfig()
|
||||
const siteUrl = computed(() => String(config.public.siteUrl || '').replace(/\/$/g, ''))
|
||||
const pageUrl = computed(() => `${siteUrl.value}/post/${post.value.slug}`)
|
||||
const seoTitle = computed(() => post.value.seoTitle || post.value.title)
|
||||
const seoDescription = computed(() => post.value.seoDescription || post.value.excerpt || 'sori.studio 개인 블로그')
|
||||
const canonicalUrl = computed(() => post.value.canonicalUrl || pageUrl.value)
|
||||
|
||||
useHead(() => ({
|
||||
title: seoTitle.value,
|
||||
link: [
|
||||
{
|
||||
rel: 'canonical',
|
||||
href: canonicalUrl.value
|
||||
}
|
||||
],
|
||||
meta: [
|
||||
{
|
||||
name: 'description',
|
||||
content: seoDescription.value
|
||||
},
|
||||
{
|
||||
name: 'robots',
|
||||
content: post.value.noindex ? 'noindex, nofollow' : 'index, follow'
|
||||
},
|
||||
{
|
||||
property: 'og:title',
|
||||
content: seoTitle.value
|
||||
},
|
||||
{
|
||||
property: 'og:description',
|
||||
content: seoDescription.value
|
||||
},
|
||||
{
|
||||
property: 'og:url',
|
||||
content: pageUrl.value
|
||||
}
|
||||
]
|
||||
}))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user