-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_page.js
37 lines (32 loc) · 983 Bytes
/
generate_page.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
const fs = require("fs");
const wordingEn = require("./assets/wording.en.json");
// templates
const headTpl = require("./templates/head.js");
const titleTpl = require("./templates/title");
const pagesTpl = require("./templates/pages/index.js");
function generateHTML() {
const contents = pagesTpl.map(({ id, content }) => {
return `<div id="${id}" class="page">${content(wordingEn)}</div>`;
});
return `<!DOCTYPE html>
<html lang="en">` +
headTpl(wordingEn) +
"<body>\n" +
titleTpl(wordingEn) +
"<div class=\"main-container\">\n" +
"<div class=\"main\">\n" +
contents.join("\n") +
"</div>\n" +
"</div>\n" +
"</body>\n" +
"</html>";
}
(function main() {
const html = generateHTML();
fs.writeFile("./index.html", html, function(err) {
if(err) {
return console.error("Could not write file: ", err);
}
console.log("Generated html with success!");
});
})();