File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
app/tags/[tag]/page/[page] Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -7,18 +7,14 @@ import { notFound } from 'next/navigation'
77
88const 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+ }
2218export default async function TagPage ( props : { params : Promise < { tag : string ; page : string } > } ) {
2319 const params = await props . params
2420 const tag = decodeURI ( params . tag )
You can’t perform that action at this time.
0 commit comments