Skip to content

fix: date sort in /blog #7513

Merged
saurabhraghuvanshii merged 5 commits intolayer5io:masterfrom
saurabhraghuvanshii:blog
Mar 17, 2026
Merged

fix: date sort in /blog #7513
saurabhraghuvanshii merged 5 commits intolayer5io:masterfrom
saurabhraghuvanshii:blog

Conversation

@saurabhraghuvanshii
Copy link
Copy Markdown
Member

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.js we add a dateForSort field for blog nodes: we parse frontmatter.date once and store a normalized 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

  • Yes, I signed my commits.

Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
@github-actions github-actions bot added area/blog New posts or new blog functionality area/site-config labels Mar 14, 2026
@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 14, 2026

🚀 Preview for commit df25260 at: https://69b5cc667678233386f42b27--layer5.netlify.app

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 15, 2026

🚀 Preview for commit 0e4e4b7 at: https://69b7039f2cfc721a904744ed--layer5.netlify.app

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 16, 2026

🚀 Preview for commit 73bc5fe at: https://69b834fa6cde525a356faa5b--layer5.netlify.app

@l5io
Copy link
Copy Markdown
Member

l5io commented Mar 17, 2026

🚀 Preview for commit a83fa9c at: https://69b936429f8b670c0fe53e81--layer5.netlify.app

@saurabhraghuvanshii saurabhraghuvanshii merged commit 2989326 into layer5io:master Mar 17, 2026
4 checks passed
@saurabhraghuvanshii saurabhraghuvanshii deleted the blog branch March 17, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/blog New posts or new blog functionality area/site-config

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants