mirror of
https://github.com/lbr77/blog-astro.git
synced 2026-04-09 00:19:12 +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 Breadcrumbs from '@/components/Breadcrumbs.astro'
|
||||||
import PageHead from '@/components/PageHead.astro'
|
import PageHead from '@/components/PageHead.astro'
|
||||||
import Layout from '@/layouts/Layout.astro'
|
import Layout from '@/layouts/Layout.astro'
|
||||||
import { getAllTags, getPostsByTag } from '@/lib/data-utils'
|
import { getPostsByTag } from '@/lib/data-utils'
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
// params.id is the tag name (string for [...id] rest parameter)
|
||||||
const tagMap = await getAllTags()
|
const tag = Astro.params.id ?? ''
|
||||||
const uniqueTags = Array.from(tagMap.keys())
|
|
||||||
|
|
||||||
return Promise.all(
|
|
||||||
uniqueTags.map(async (tag) => {
|
|
||||||
const posts = await getPostsByTag(tag)
|
const posts = await getPostsByTag(tag)
|
||||||
return {
|
|
||||||
params: { id: tag },
|
|
||||||
props: {
|
|
||||||
tag,
|
|
||||||
posts,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const { tag, posts } = Astro.props
|
|
||||||
export const prerender = false
|
export const prerender = false
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user