-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.ts
53 lines (45 loc) · 1.44 KB
/
convert.ts
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import rehypeParse from "https://esm.sh/rehype-parse";
import rehypeRemark from "https://esm.sh/rehype-remark";
import remarkStringify from "https://esm.sh/remark-stringify";
import remarkFrontmatter from "https://esm.sh/remark-frontmatter@5";
import { stringify } from "https://esm.sh/yaml";
import * as d3 from "https://esm.sh/d3-dsv";
import { unified } from "https://esm.sh/unified";
const blog = d3.csvParse(Deno.readTextFileSync("./webflow/blog.csv"));
for (let post of blog) {
const { Slug, "Post Body": body, ...rest } = post;
const file = await unified()
.use(rehypeParse)
.use(rehypeRemark)
.use(remarkFrontmatter, ["yaml"])
.use(remarkStringify)
.use(function () {
return function (tree) {
tree.children.unshift({
type: "yaml",
value: stringify(rest),
});
};
})
.process(body);
Deno.writeTextFileSync(`./blog/${Slug}.md`, String(file));
}
const docs = d3.csvParse(Deno.readTextFileSync("./webflow/docs.csv"));
for (let post of docs) {
const { Slug, Body: body, ...rest } = post;
const file = await unified()
.use(rehypeParse)
.use(rehypeRemark)
.use(remarkFrontmatter, ["yaml"])
.use(remarkStringify)
.use(function () {
return function (tree) {
tree.children.unshift({
type: "yaml",
value: stringify(rest),
});
};
})
.process(body);
Deno.writeTextFileSync(`./docs/${Slug}.md`, String(file));
}