fix: date sort in /blog #7513
Merged
saurabhraghuvanshii merged 5 commits intolayer5io:masterfrom Mar 17, 2026
Merged
Conversation
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
Member
|
🚀 Preview for commit df25260 at: https://69b5cc667678233386f42b27--layer5.netlify.app |
Member
|
🚀 Preview for commit 0e4e4b7 at: https://69b7039f2cfc721a904744ed--layer5.netlify.app |
Member
|
🚀 Preview for commit 73bc5fe at: https://69b834fa6cde525a356faa5b--layer5.netlify.app |
Rajesh-Nagarajan-11
approved these changes
Mar 17, 2026
Member
|
🚀 Preview for commit a83fa9c at: https://69b936429f8b670c0fe53e81--layer5.netlify.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Root cause: Sorting used frontmatter.date, which is inconsistent across blog posts (mixed quoted/unquoted dates and timezones). In production, that led to unstable/non-deterministic order.
Fix:
In
gatsby-node.jswe add adateForSortfield for blog nodes: we parse frontmatter.date once and store anormalized ISO string. All blog queries (main listing, category/tag pages, related posts, RSS feed) now use sort: { fields: { dateForSort: DESC } } instead of frontmatter.date, so order is stable in every environment. The blog page also guards against missing query data (data?.allMdx?.nodes ?? []) to avoid runtime errors.This PR fixes #
Notes for Reviewers
Signed commits