-
Notifications
You must be signed in to change notification settings - Fork 0
/
presskit.js
33 lines (27 loc) · 951 Bytes
/
presskit.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
var fs = require("fs");
var handlebars = require("handlebars");
var presskitData = require("./presskit.json");
var presskitTemplate = "./presskit.hbs";
var presskitDestination = "./out/press/index.html";
createPresskit(presskitData, presskitTemplate, presskitDestination);
function createPresskit(data, template, destination) {
fs.writeFileSync(destination, renderFromExternalTemplate(template, data));
}
function renderFromExternalTemplate(templateFile, data){
var file = fs.readFileSync(templateFile, "utf8");
var template = handlebars.compile(file);
return template(data);
}
// function replaceAll(str, find, replace) {
// return str.replace(new RegExp(find, 'g'), replace);
// }
// function getPageLinks(pages) {
// var data = [];
// for (var i = 0; i < pages.length; i++) {
// data.push({
// "fileName": pages[i].fileName,
// "pageName": pages[i].pageName
// });
// }
// return data;
// }