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}