일반 태그 상세 메타 표시 수정
This commit is contained in:
@@ -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}`
|
||||
})))
|
||||
|
||||
Reference in New Issue
Block a user