From 7a2fb2a5f08806f3a85b9da73b477ca83911a3d8 Mon Sep 17 00:00:00 2001 From: Bingus_Violet Date: Fri, 5 Jan 2024 14:04:48 -0600 Subject: [PATCH] Finally sorted by date --- index.js | 13 ++++++++++++- resources/mainPage.html | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4fea7d3..232717f 100644 --- a/index.js +++ b/index.js @@ -33,7 +33,18 @@ app.listen(PORT, () => { }) function pageUpdate() { - var postsArray = fs.readdirSync(postsPath) + var postsArray = fs.readdirSync(postsPath, function(err, files){ + files = files.map(function (fileName) { + return { + name: fileName, + time: fs.statSync(dir + '/' + fileName).mtime.getTime() + }; + }) + .sort(function (a, b) { + return a.time - b.time; }) + .map(function (v) { + return v.name; }); + }) var posts = {} for (let index = 0; index < postsArray.length; index++) { diff --git a/resources/mainPage.html b/resources/mainPage.html index 28bf2db..6e4a18f 100644 --- a/resources/mainPage.html +++ b/resources/mainPage.html @@ -8,7 +8,8 @@ -

Welcome to Violet's Limbo!

+ Home +

Violet's Limbo!

Posts:

{POSTS}