-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-presentations.js
51 lines (45 loc) · 1.54 KB
/
generate-presentations.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { exec } = require("child_process");
const path = require("path");
const fs = require("fs");
const rimraf = require("rimraf");
// note expects reveal-md installed globally
const generateStaticPresentation = (markdownPath, themePath) => {
const presentationName = path.basename(markdownPath, '.md');
rimraf(`presentations/${presentationName}`, {}).then(() =>
function () { console.log("done"); });
// todo: add theme support
const revealCommand = `reveal-md ./${markdownPath} --theme ../../theme/my-theme.css --static=presentations/${presentationName}`;
console.log("command: ", revealCommand);
exec(revealCommand, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
};
const collectAllPresentations = () => {
const presentationsDir = "presentations";
let presentations = [];
fs.readdirSync(presentationsDir).forEach(file => {
console.log("File ", path.extname(file));
const filePath = path.join(presentationsDir, file);
const stats = fs.statSync(filePath);
// todo: add support for themes
if (path.extname(file) === ".md") {
presentations.push(filePath)
}
});
console.log("Presentations: ", presentations);
return presentations;
};
generateAllStaticPresentations = () => {
collectAllPresentations().forEach(presentationPath => {
generateStaticPresentation(presentationPath);
})
}
generateAllStaticPresentations();