feat: blog home pagination and routing #348
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✨ What’s Changed
This PR introduces pagination and route refactor for the blog:
?page=n
query param and GraphQLskip
logic./blog/page.tsx
./
) from the blog page (/blog
) to allow better customization and demonstration of routing versions.🔧 Technical Details
pageBlogPostCollection
GraphQL query withskip
andlimit
parameters for pagination.page.tsx
withsearchParams.page
to fetch paginated content.BlogPosts
component using aContainer
layout.useRouter().push()
handles?page=n
navigation.🧪 How to Test
/blog
.?page=2
,?page=3
, etc.).Previous
andNext
buttons work and are disabled at page limits./
still functions independently and is not affected by this change.🚫 Breaking Changes
/
) and blog routes are now structurally separated.📦 Folder Structure Affected
/blog/page.tsx
– new structured blog index routelib/fetchPosts.ts
– GraphQL logic for paginated fetchcomponents/features/blog/BlogPosts.tsx
– blog UI rendering with pagination supportcomponents/ui/Pagination.tsx
– reusable pagination UI component✅ Strengths & Highlights
✅ Clean Pagination via Query Parameters (
?page=n
)✅ GraphQL Pagination with
skip
andlimit
✅ Routing Separation (
/blog/page.tsx
)/
as a clean, standalone landing page./blog
to evolve independently as a CMS-powered section.✅ Pagination UI Implementation
useRouter().push()
for navigation.❌ 1. No Total Page Count = No Last Page Guard
❌ 2. No Loading State on Pagination Click
🚀 Ideal Starter Use Case
This setup is perfect for developers building a simple blog or documentation site with:
/
) for branding, marketing, or announcements./blog
) using clean routes and scalable structure.components/
,lib/
, andapp/blog/
.Highlights for starters:
BlogPosts.tsx
), card style, or pagination logic.🛠️ Want to turn
/
into your landing site and/blog
into a dynamic content hub?→ This is your foundation. Just plug in your CMS and deploy.