Skip to content

Commit afa6add

Browse files
committed
Update page.tsx
1 parent fbd948a commit afa6add

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

app/tags/[tag]/page/[page]/page.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ import { notFound } from 'next/navigation'
77

88
const POSTS_PER_PAGE = 5
99

10-
export const generateStaticParams = async () => {
11-
const tagCounts = tagData as Record<string, number>
12-
return Object.keys(tagCounts).flatMap((tag) => {
13-
const postCount = tagCounts[tag]
14-
const totalPages = Math.max(1, Math.ceil(postCount / POSTS_PER_PAGE))
15-
return Array.from({ length: totalPages }, (_, i) => ({
16-
tag: encodeURI(tag),
17-
page: (i + 1).toString(),
18-
}))
19-
})
20-
}
10+
export async function generateStaticParams() {
11+
const blogs = allBlogs.map((post) => post.tags || []).flat()
12+
const allTags = [...new Set([...blogs])]
2113

14+
return allTags.map((tag) => ({
15+
tag: tag,
16+
}))
17+
}
2218
export default async function TagPage(props: { params: Promise<{ tag: string; page: string }> }) {
2319
const params = await props.params
2420
const tag = decodeURI(params.tag)

0 commit comments

Comments
 (0)