From 20931aa4b919284f0485c12743278df922477a9e Mon Sep 17 00:00:00 2001 From: Joone Hur Date: Sun, 24 Mar 2024 20:26:17 -0700 Subject: [PATCH] Update post sorting to use Date objects Update the post sorting logic to use Date objects for better comparison accuracy and consistency. --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index baf088a6..06695c30 100644 --- a/src/index.js +++ b/src/index.js @@ -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);