-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmigration.js
34 lines (32 loc) · 818 Bytes
/
migration.js
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
27
28
29
30
31
32
33
34
"use strict";
const mdify = require("mdify")
, readFile = require("read-utf8")
, fs = require("fs")
, rJson = require("r-json")
;
const articles = rJson("content/articles/index.json");
articles.forEach(c => {
let path = "content/articles/" + c.id + ".md";
let content = readFile(path);
if (content.startsWith("---")) {
return
}
mdify.writeFile(path, {
title: c.title,
date: c.date,
author: c.by,
tags: c.tags
}, content);
});
const pages = rJson("content/pages/index.json");
pages.forEach(c => {
let path = "content/pages/" + c.slug + ".md";
let content = readFile(path);
if (content.startsWith("---")) {
return
}
mdify.writeFile(path, {
title: c.title,
order: c.order
}, content);
});