Skip to content

Commit

Permalink
Update post sorting to use Date objects
Browse files Browse the repository at this point in the history
Update the post sorting logic to use Date objects for better
comparison accuracy and consistency.
  • Loading branch information
joone committed Mar 25, 2024
1 parent d2a64fe commit 20931aa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const posts = fs
.readdirSync(config.dev.postsdir)
.map(post => postMethods.readArticle(post))
.sort(function(a, b) {
return b.attributes.date - a.attributes.date;
return new Date(b.attributes.date) - new Date(a.attributes.date);
});

if (!fs.existsSync(config.dev.outdir)) fs.mkdirSync(config.dev.outdir);
Expand Down

0 comments on commit 20931aa

Please sign in to comment.