mirror of
https://github.com/lbr77/blog-astro.git
synced 2026-04-08 16:11:56 +00:00
fix: tag not found
This commit is contained in:
@@ -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
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user