1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import fs from 'fs'
import k from '../api'
let posts = k.getPosts()
posts = posts.map(({ date, title, content, route }) => {
const { year, month, day } = date
const { description, meta } = content
return {
date: `${year}-${month}-${day}`,
title,
content: { description, meta },
route
}
})
fs.writeFile('./dist/api/posts.json', JSON.stringify(posts), err =>
err ? console.log(err) : null
)
fs.writeFile('./static/api/posts.json', JSON.stringify(posts), err =>
err ? console.log(err) : null
)
console.log(posts)
|