about summary refs log tree commit diff
path: root/scripts/generateApi.js
blob: 27af063706be423bd2e5f5f9dcd6b7e598a639f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const fs = require('fs')

let { getPosts } = require('../api/api')

let posts = getPosts()

posts = posts.map(({ year, month, day, title, attributes, route }) => {
    return {
        date: `${year}-${month}-${day}`,
        title,
        attributes,
        route
    }
})

posts.sort((a, b) => (a.route > b.route ? 1 : -1))

fs.writeFile('./dist/api/posts.json', JSON.stringify(posts), (err) => err ? console.log(err) : null)
console.log(posts)