Pagination in server components in app directory
Unanswered
Pembroke Welsh Corgi posted this in #help-forum
Pembroke Welsh CorgiOP
i'm building a blog with the app directory and contentful. i want to add pagination to it and also filter the bloglist by tag/category.
i.e. I would have routes like
How do i implement the folder structure and pagination for something like this.
This is what my current project structure look like but I feel it can be better
Thanks
i.e. I would have routes like
blog/[category] or blog/[pageNumber] or blog/[category]/[pageNumber] and ofcourse blog/[this-slug].How do i implement the folder structure and pagination for something like this.
This is what my current project structure look like but I feel it can be better
blog/page/1/tag/tag-name/blog
page.tsx
/[slug]
page.tsx
/page
page.tsx
/[page]
page.tsx
/tag
[tag]
page.tsxThanks
11 Replies
@Pembroke Welsh Corgi i'm building a blog with the app directory and contentful. i want to add pagination to it and also filter the bloglist by tag/category.
i.e. I would have routes like `blog/[category]` or `blog/[pageNumber]` or `blog/[category]/[pageNumber]` and ofcourse `blog/[this-slug]`.
How do i implement the folder structure and pagination for something like this.
This is what my current project structure look like but I feel it can be better
`blog/page/1/tag/tag-name`
/blog
page.tsx
/[slug]
page.tsx
/page
page.tsx
/[page]
page.tsx
/tag
[tag]
page.tsx
Thanks
Hmm i think thats going to be tricky since you have to differentiate between
blog/[category] and
blog/[pageNumber]
Best you can do is to store the pagination in a searchparam
blog/[category] and
blog/[pageNumber]
Best you can do is to store the pagination in a searchparam
@alfon Hmm i think thats going to be tricky since you have to differentiate between
blog/[category] and
blog/[pageNumber]
Best you can do is to store the pagination in a searchparam
Pembroke Welsh CorgiOP
hmm, that means I can't use SSG here since searchParam is dynamic
Well
If you already know all the pageNumber and Category i suppose you can
But you might want to boil it down to just
blog/[[slug]]
blog/[[slug]]
Asian black bear
quick easy idea: you could have a different path for blog posts and blog lists
blog/[slug]
posts/[category]/[page]
posts/[category]/[page]
@alfon But you might want to boil it down to just
blog/[[slug]]
Pembroke Welsh CorgiOP
okay, I wonder how i'll be able to differentiate a
blog/[slug] or blog/[category] here@Asian black bear blog/[slug]
posts/[category]/[page]
Pembroke Welsh CorgiOP
oh cool,I'll try this. Thanks
You can try what minabot said
blog/[pagenumber]
blog/category/[categoryname]/[pagemumber]
blog/other/[slug]
blog/[pagenumber]
blog/category/[categoryname]/[pagemumber]
blog/other/[slug]