49 lines
1.0 KiB
JavaScript
Raw Normal View History

var Fs = require("fs");
// read a file
var read = function (path) {
return Fs.readFileSync(path, 'utf-8');
};
// write a file
var write = function (path, src) {
return Fs.writeFileSync(path, src);
};
// basic templating
var swap = function (src, dict) {
return src.replace(/\{\{(.*?)\}\}/g, function (a, b) {
return dict[b] || b;
});
};
// read the template file
var template = read('./template.html');
// read page fragments
var fragments = {};
2016-12-28 15:52:16 +01:00
[ 'index',
'fork',
2017-01-16 18:28:37 +01:00
'topbar',
'terms',
'privacy',
'about',
2017-01-16 18:28:37 +01:00
'contact',
2016-12-28 15:52:16 +01:00
'logo',
'noscript',
].forEach(function (name) {
fragments[name] = read('./fragments/' + name + '.html');
});
// build static pages
2017-01-16 18:28:37 +01:00
['index', 'privacy', 'terms', 'about', 'contact',].forEach(function (page) {
var source = swap(template, {
2017-01-16 18:28:37 +01:00
topbar: fragments.topbar,
fork: fragments.fork,
main: fragments[page],
2016-12-28 15:52:16 +01:00
logo: fragments.logo,
noscript: fragments.noscript,
});
write('../' + page + '.html', source);
});