-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (36 loc) · 824 Bytes
/
index.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
35
36
37
38
const fs = require("fs"),
ejs = require("ejs"),
paths = require("path"),
minify = require("html-minifier").minify,
projs = require("./projects");
function ejsToHTML(path) {
ejs.renderFile(
path,
{
projects: projs.array,
views: paths.resolve(__dirname, "src"),
},
(err, html) => {
const minified = minify(html, {
collapseBooleanAttributes: true,
collapseWhitespace: true,
});
if (err) {
console.error(err);
return false;
}
fs.writeFile(
paths.resolve(__dirname, "public", "index.html"),
minified,
function (err) {
if (err) {
console.log(err);
return false;
}
return true;
}
);
}
);
}
ejsToHTML(__dirname + "/src/index.ejs");