Finally sorted by date

This commit is contained in:
Bingus_Violet 2024-01-05 14:04:48 -06:00
parent 9772637055
commit 7a2fb2a5f0
2 changed files with 14 additions and 2 deletions

View file

@ -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++) {

View file

@ -8,7 +8,8 @@
<link rel="stylesheet" href="https://violets-purgatory.dev/style.css">
</head>
<body>
<h1>Welcome to Violet's Limbo!</h1>
<a>Home</a>
<h1>Violet's Limbo!</h1>
<h2>Posts:</h2>
{POSTS}
</body>