forked from SEU-ESG/SEU-ESG.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
24 lines (20 loc) · 915 Bytes
/
build.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
const ejs = require('ejs');
const minify = require('html-minifier').minify;
const yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
// Read the configuration file
const global = yaml.load(fs.readFileSync(path.join(__dirname, 'configs/global.yaml'), 'utf8'));
const schedules = yaml.load(fs.readFileSync(path.join(__dirname, 'configs/schedules.yaml'), 'utf8'));
// Render global.upcoming
latest = schedules[0];
global.upcoming = `${latest.presenter} will present a/an ${latest.conf} paper on ${latest.time}, ${latest.date} at ${latest.location}.`;
// Render index.ejs
const index = minify(ejs.render(fs.readFileSync(path.join(__dirname, 'index.ejs'), 'utf8'), { global, schedules }), {
collapseWhitespace: true,
removeComments: true,
minifyJS: true,
minifyCSS: true
});
// Write the rendered HTML to index.html
fs.writeFileSync(path.join(__dirname, 'index.html'), index);