-
Notifications
You must be signed in to change notification settings - Fork 0
fix(frontend): align paginated posts routing #656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Coverage Report for Storybook Tests
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Hardens /posts/page/[pageNumber] routing to avoid invalid/duplicate pagination routes and keep runtime pagination logic aligned with static route generation, improving canonical navigation and reducing SEO duplication.
Changes:
- Validate and canonicalize paginated posts routes (redirect
/posts/page/1→/posts,notFound()for invalid/out-of-range pages). - Introduce
POSTS_PER_PAGE = 12and reuse it in bothfindandgenerateStaticParams(static params start at page 2). - Update the Pagination molecule to navigate to
/postswhen the target page is 1, and add regression tests for routing + molecule navigation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/app/(frontend)/posts/page/[pageNumber]/page.tsx |
Adds page param validation, canonical redirect for page 1, bounds checking, and aligns static params with runtime page size. |
src/components/molecules/Pagination/index.tsx |
Canonicalizes navigation to /posts when the target page is 1. |
tests/unit/components/paginationMolecule.test.tsx |
Adds molecule-level regression tests for canonical navigation to /posts. |
tests/unit/app/frontend/posts/paginatedPostsPage.test.ts |
Adds route-level tests for redirect/notFound behavior and static param generation consistency. |
Coverage Report for Integration Tests
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary: This PR hardens paginated blog routing to prevent invalid or duplicate pages and canonicalizes page-1 navigation. It also aligns static route generation with runtime pagination settings.
Changes:
pageNumberas digits-only, parse safely, and reject non-positive values in/src/app/(frontend)/posts/page/[pageNumber]/page.tsx./posts/page/1to canonical/posts.notFound()when a requested page is out of range (no docs or page > total pages).POSTS_PER_PAGE = 12and reuse it for bothpayload.findandgenerateStaticParams./src/components/molecules/Pagination/index.tsxto navigate to/postswhen target page is 1.Why:
/postsvs/posts/page/1, invalid page numbers, and mismatched static/runtime page calculations). This caused inconsistent navigation behavior and avoidable SEO duplication risk.Testing:
pnpm vitest run tests/unit/components/paginationMolecule.test.tsx tests/unit/app/frontend/posts/paginatedPostsPage.test.tspnpm exec eslint src/app/'(frontend)'/posts/page/'[pageNumber]'/page.tsx src/components/molecules/Pagination/index.tsx tests/unit/components/paginationMolecule.test.tsx tests/unit/app/frontend/posts/paginatedPostsPage.test.tspnpm run checkcurrently fails due pre-existing unrelated TypeScript issues in auth tests (missingcollectionfield in fixtures).Related: None
Breaking changes: None