게시물 상세 이동 지연 개선 및 전체 목록 조회 제거 (v1.10.37)

- 본문만 블로킹 조회, 태그·광고는 lazy로 전환
- 이전·다음 글을 상세 API에서 window 함수로 계산해 응답에 포함
- 전체 게시물(본문 포함) 조회 제거, 광고 site-settings 캐시 재사용

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-03 18:54:08 +09:00
parent a07d0350c2
commit 8a774a1874
6 changed files with 95 additions and 24 deletions

View File

@@ -8,14 +8,15 @@ definePageMeta({
const route = useRoute()
const slug = computed(() => String(route.params.slug || ''))
// 본문은 화면 구성의 필수 데이터이므로 블로킹으로 받아 이동 시점에 완성된 글을 보여준다.
// 이전·다음 글은 상세 응답에 포함되어 별도 목록 요청 없이 즉시 표시된다.
const { data: post } = await useFetch(() => `/api/posts/${slug.value}`)
const { data: tags } = await useFetch('/api/tags?tagType=all', {
// 태그 표시명/색, 광고는 이동을 막지 않도록 lazy로 받아 이동 후 채운다.
const { data: tags } = useLazyFetch('/api/tags?tagType=all', {
default: () => []
})
const { data: posts } = await useFetch('/api/posts', {
default: () => []
})
const { data: siteSettings } = await useFetch('/api/site-settings', {
const { data: siteSettings } = useLazyFetch('/api/site-settings', {
key: 'site-settings-public',
default: () => ({})
})
const postToc = useState('post-detail-toc', () => [])
@@ -59,21 +60,12 @@ const canEditPost = computed(() => Boolean(
))
const postEditPath = computed(() => `/admin/posts/${post.value.id}`)
const currentIndex = computed(() => posts.value.findIndex((item) => item.slug === post.value.slug))
const previousPost = computed(() => {
if (currentIndex.value <= 0) {
return null
}
const candidate = posts.value[currentIndex.value - 1]
const candidate = post.value?.previous
return candidate ? { title: candidate.title, to: `/post/${candidate.slug}` } : null
})
const nextPost = computed(() => {
if (currentIndex.value === -1 || currentIndex.value >= posts.value.length - 1) {
return null
}
const candidate = posts.value[currentIndex.value + 1]
const candidate = post.value?.next
return candidate ? { title: candidate.title, to: `/post/${candidate.slug}` } : null
})