일반 태그 상세 메타 표시 수정

This commit is contained in:
2026-06-26 17:42:16 +09:00
parent a39317f25c
commit 6d74425415
14 changed files with 90 additions and 29 deletions

View File

@@ -3,6 +3,23 @@ const { data: posts } = await useFetch('/api/posts', {
default: () => []
})
const { data: tags } = await useFetch('/api/tags?tagType=all', {
default: () => []
})
/**
* 태그 슬러그로 공개 태그 이름을 찾는다.
* @param {string | undefined} slug - 태그 슬러그
* @returns {string} 태그 이름
*/
const getTagName = (slug) => {
if (!slug) {
return ''
}
return tags.value.find((tag) => tag.slug === slug)?.name || String(slug).toUpperCase()
}
const postCards = computed(() => posts.value.map((post) => ({
title: post.title,
excerpt: createPostSummary(post.excerpt, post.content, {
@@ -11,7 +28,7 @@ const postCards = computed(() => posts.value.map((post) => ({
}),
featuredImage: post.featuredImage,
featuredImageThumbnail: post.featuredImageThumbnail || '',
tag: post.tags?.[0] ? String(post.tags[0]).toUpperCase() : '',
tag: getTagName(post.tags?.[0]),
publishedAt: formatPostDate(post.publishedAt),
to: `/post/${post.slug}`
})))