Skip to content

Commit c6fc0ba

Browse files
committed
feat: implement yaml splash
1 parent 1d09f79 commit c6fc0ba

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

build/template.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import dotenv from "dotenv";
77
import { JSDOM } from "jsdom";
88
import * as FileSystem from "node:fs/promises";
99
import { Marked } from "marked";
10+
import YAML from "yaml";
1011

1112
dotenv.config();
1213

@@ -39,13 +40,10 @@ const template = {
3940
},
4041
header: {
4142
splash:
42-
FileSystem.readFile("./content/splash.txt", "utf8")
43+
FileSystem.readFile("./content/splash.yaml", "utf8")
4344
.then(string => {
44-
const array = string
45-
.replace(/\s+\/\/.*/g, "") // remove comments
46-
.replace(/\n(?!\S+)/g, "") // remove empty lines
47-
.split("\n");
48-
const splash = array[Math.floor(Math.random() * array.length)];
45+
const array = YAML.parse(string);
46+
const { splash } = array[Math.floor(Math.random() * array.length)];
4947
return splash
5048
.replace(/<((?!\/>).+?)>/g, "<span class=\"splash-$1\">")
5149
.replace(/<\/>/g, "</span>")

0 commit comments

Comments
 (0)