fix: tag not found

This commit is contained in:
2026-01-19 18:12:13 +08:00
parent ee7012ace9
commit ef4fab2cb6

View File

@@ -3,27 +3,11 @@ import BlogCard from '@/components/BlogCard.astro'
import Breadcrumbs from '@/components/Breadcrumbs.astro'
import PageHead from '@/components/PageHead.astro'
import Layout from '@/layouts/Layout.astro'
import { getAllTags, getPostsByTag } from '@/lib/data-utils'
import { getPostsByTag } from '@/lib/data-utils'
export async function getStaticPaths() {
const tagMap = await getAllTags()
const uniqueTags = Array.from(tagMap.keys())
return Promise.all(
uniqueTags.map(async (tag) => {
const posts = await getPostsByTag(tag)
return {
params: { id: tag },
props: {
tag,
posts,
},
}
}),
)
}
const { tag, posts } = Astro.props
// params.id is the tag name (string for [...id] rest parameter)
const tag = Astro.params.id ?? ''
const posts = await getPostsByTag(tag)
export const prerender = false
---