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": {
|
||||
"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-html": "cp src/index.html build/index.html",
|
||||
"build": "mkdir -p build && npm run build-js && npm run build-css && npm run build-html",
|
||||
"build-html": "node src/build-html.js",
|
||||
"build": "rm -r build/ && mkdir -p build/ && npm run build-js && npm run build-css && npm run build-html",
|
||||
"start": "tstatic build/"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -22,7 +22,9 @@
|
|||
"homepage": "https://github.com/RealOrangeOne/presentation-base#readme",
|
||||
"devDependencies": {
|
||||
"browserify": "14.4.0",
|
||||
"node-sass": "4.5.3"
|
||||
"glob": "7.1.2",
|
||||
"node-sass": "4.5.3",
|
||||
"underscore": "1.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"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>
|
||||
<div class="reveal">
|
||||
<div class="slides">
|
||||
<section>
|
||||
<h1>Title</h1>
|
||||
<h4><i>Subtitle</i></h4>
|
||||
</section>
|
||||
{{ slides }}
|
||||
</div>
|
||||
</div>
|
||||
<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