-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconvert.ts
39 lines (30 loc) · 1.04 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
import { parse, stringify} from 'https://deno.land/[email protected]/encoding/yaml.ts'
const prefix = "---\n\
layout: talk\n\
";
function createFilename (title: string) {
return title.replaceAll('&','+')
.replaceAll(';', '')
.replaceAll(':', '')
.replaceAll('`', '')
.replaceAll('’', '')
.replaceAll('\'', '')
.replaceAll(',', '')
.replaceAll(' ', '-')
.toLowerCase() + ".md"
}
function convertContent(content: string){
return prefix
+ content.replace('name:', 'title:')
.replace('authors:', 'speakers:')
.replace('author:', 'speakers:')
+ "\n---\n\n" + talk.summary
}
const file = Deno.readTextFileSync('./_data/talks.yml', 'utf8')
const data = parse(file);
for (var talk of data) {
talk.index = (43 - data.indexOf(talk));
talk.header = { image: 'talks' };
Deno.writeTextFileSync("./_talks/" + createFilename(talk.name),
convertContent(stringify(talk)));
}