-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix reversed blog navigation links (#7844) #8244
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
base: main
Are you sure you want to change the base?
Fix reversed blog navigation links (#7844) #8244
Conversation
Improve the explanation in the 'Fetching data' section to clearly distinguish when an Effect is needed (synchronization with external system) versus when it's not needed (user events, data transformation). Closes reactjs#8226
Swap prevRoute and nextRoute for blog posts to fix navigation direction. Blog posts are ordered newest to oldest, so the traversal order is reversed from chronological order. - Previous link now correctly points to older posts - Next link now correctly points to newer posts This only affects blog posts, other sections remain unchanged. Fixes reactjs#7844
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 Five Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
dakshverma23
left a comment
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.
LGTM — fixes blog footer nav and clarifies the effects doc. Please add a one-line comment in Page.tsx explaining why next/prev are swapped for blog posts.
Add one-line comment explaining why next/prev routes are swapped for blog posts (they're ordered newest to oldest).
|
Done! Added the comment. Thanks for the review! 🙌
|
Summary
Fixes reversed blog navigation links where "Previous" pointed to newer posts and "Next" pointed to older posts (reported in #7844).
Problem
Blog posts in
sidebarBlog.jsonare ordered from newest to oldest (chronologically descending). ThegetRouteMetafunction uses depth-first traversal, which sets:prevRoute= routes that come before in traversal (newer posts)nextRoute= routes that come after in traversal (older posts)This caused "Previous" to point to newer posts and "Next" to point to older posts, which is backwards from expected blog navigation UX.
Solution
Swap
prevRouteandnextRoutespecifically for blog posts (section === 'blog') before passing them toDocsPageFooter. This ensures:Changes
Page.tsxto swap routes only for blog section (lines 99-100)Testing
✅ Verified locally:
http://localhost:3000/blog/2025/04/23/react-labs-view-transitions-activity-and-moreBefore fix:
After fix:
Fixes #7844