Compile slides files rather than use 1 file
This commit is contained in:
parent
c2a20a3a8d
commit
7bfc096eb0
5 changed files with 37 additions and 7 deletions
|
@ -6,8 +6,8 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build-js": "browserify src/index.js -o build/index.js && cp -r node_modules/reveal.js/plugin build/ && cp node_modules/reveal.js/lib/js/head.min.js build/head.min.js",
|
"build-js": "browserify src/index.js -o build/index.js && cp -r node_modules/reveal.js/plugin build/ && cp node_modules/reveal.js/lib/js/head.min.js build/head.min.js",
|
||||||
"build-css": "node-sass src/index.scss build/index.css --source-map-embed",
|
"build-css": "node-sass src/index.scss build/index.css --source-map-embed",
|
||||||
"build-html": "cp src/index.html build/index.html",
|
"build-html": "node src/build-html.js",
|
||||||
"build": "mkdir -p build && npm run build-js && npm run build-css && npm run build-html",
|
"build": "rm -r build/ && mkdir -p build/ && npm run build-js && npm run build-css && npm run build-html",
|
||||||
"start": "tstatic build/"
|
"start": "tstatic build/"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -22,7 +22,9 @@
|
||||||
"homepage": "https://github.com/RealOrangeOne/presentation-base#readme",
|
"homepage": "https://github.com/RealOrangeOne/presentation-base#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browserify": "14.4.0",
|
"browserify": "14.4.0",
|
||||||
"node-sass": "4.5.3"
|
"glob": "7.1.2",
|
||||||
|
"node-sass": "4.5.3",
|
||||||
|
"underscore": "1.8.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"highlight.js": "9.12.0",
|
"highlight.js": "9.12.0",
|
||||||
|
|
23
src/build-html.js
Normal file
23
src/build-html.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
const glob = require('glob');
|
||||||
|
const fs = require('fs');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const handlebars = require('handlebars');
|
||||||
|
|
||||||
|
function sorter(path) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = _.sortBy(glob.sync('src/slides/*.html'), sorter);
|
||||||
|
|
||||||
|
|
||||||
|
const readFiles = files.map(function (file) {
|
||||||
|
return fs.readFileSync(file).toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
const context = {
|
||||||
|
slides: new handlebars.SafeString(readFiles.join(''))
|
||||||
|
};
|
||||||
|
|
||||||
|
const template = handlebars.compile(fs.readFileSync('src/index.html').toString());
|
||||||
|
|
||||||
|
fs.writeFileSync('build/index.html', template(context));
|
|
@ -8,10 +8,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="reveal">
|
<div class="reveal">
|
||||||
<div class="slides">
|
<div class="slides">
|
||||||
<section>
|
{{ slides }}
|
||||||
<h1>Title</h1>
|
|
||||||
<h4><i>Subtitle</i></h4>
|
|
||||||
</section>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src='index.js'></script>
|
<script src='index.js'></script>
|
||||||
|
|
4
src/slides/1.html
Normal file
4
src/slides/1.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<section>
|
||||||
|
<h1>Title</h1>
|
||||||
|
<h4><i>Subtitle</i></h4>
|
||||||
|
</section>
|
4
src/slides/2.html
Normal file
4
src/slides/2.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<section>
|
||||||
|
<h1>Other Title</h1>
|
||||||
|
<h4><i>Subtitle</i></h4>
|
||||||
|
</section>
|
Reference in a new issue