Skip to content

Commit a59b459

Browse files
fix graphql error
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
1 parent cf8b455 commit a59b459

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

gatsby-node.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -863,23 +863,20 @@ exports.onCreateNode = ({ node, actions, getNode }) => {
863863
value: collection,
864864
});
865865

866-
// Normalize blog date to ISO string for stable sort order across build environments (fixes production blog order)
867-
if (collection === "blog") {
868-
let dateForSort = "1970-01-01T00:00:00.000Z";
869-
if (node.frontmatter?.date != null) {
870-
try {
871-
const parsed = new Date(node.frontmatter.date).toISOString();
872-
if (!Number.isNaN(Date.parse(parsed))) dateForSort = parsed;
873-
} catch {
874-
// keep fallback
875-
}
866+
let dateForSort = "1970-01-01T00:00:00.000Z";
867+
if (node.frontmatter?.date != null) {
868+
try {
869+
const parsed = new Date(node.frontmatter.date).toISOString();
870+
if (!Number.isNaN(Date.parse(parsed))) dateForSort = parsed;
871+
} catch {
872+
// Keep fallback.
876873
}
877-
createNodeField({
878-
name: "dateForSort",
879-
node,
880-
value: dateForSort,
881-
});
882874
}
875+
createNodeField({
876+
name: "dateForSort",
877+
node,
878+
value: dateForSort,
879+
});
883880

884881
if (collection !== "content-learn") {
885882
let slug = "";

0 commit comments

Comments
 (0)