Sort posts by date

This commit is contained in:
LordMathis 2018-07-08 14:37:27 +02:00
parent 72e5df5ae8
commit 772e217fb9
1 changed files with 3 additions and 0 deletions

View File

@ -6,6 +6,9 @@ const config = require('./config.json');
api.get('/blog', (req, res) => {
res.set('Cache-Control', 'no-cache');
data.posts.sort((a,b) => {
return new Date(b.published) - new Date(a.published);
})
res.json(data.posts);
});