File size: 1,001 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"use strict";
const fs = require("fs");
const ejs = require("ejs");
const path = require("path");
const data = require("./vars");
const tpl = fs.readFileSync(__dirname + "/template.ejs").toString();
const version = require('../../package.json').version;

const base = process.env.CONTENT_BASE;
if (typeof base !== "string") {
  throw new Error("env CONTENT_BASE is required to be set.");
}
const banner =
  "Do not edit this file! It is generated by `generate.js` in this folder, from `template.ejs` and " +
  "vars.js.";

data.forEach(function(datum, i) {
  datum.base = base.replace(/\/$/, ""); // trim trailing slash
  datum.index = (i).toLocaleString('en-US', {minimumIntegerDigits: 2, useGrouping:false});
  datum.banner = banner;
  datum.previous = data[i - 1];
  datum.next = data[i + 1];
  datum.version = version;
});

data.forEach(function(datum, i) {
  const html = ejs.render(tpl, datum);
  fs.writeFileSync(path.resolve(__dirname, '..', `${datum.index}-${datum.source}.html`), html);
});