diff --git a/package.json b/package.json index 54a90e9..57a7cef 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/build-html.js b/src/build-html.js new file mode 100644 index 0000000..4f3a3ac --- /dev/null +++ b/src/build-html.js @@ -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)); diff --git a/src/index.html b/src/index.html index 6405f8c..402d5f0 100644 --- a/src/index.html +++ b/src/index.html @@ -8,10 +8,7 @@
-
-

Title

-

Subtitle

-
+ {{ slides }}
diff --git a/src/slides/1.html b/src/slides/1.html new file mode 100644 index 0000000..4269fe0 --- /dev/null +++ b/src/slides/1.html @@ -0,0 +1,4 @@ +
+

Title

+

Subtitle

+
diff --git a/src/slides/2.html b/src/slides/2.html new file mode 100644 index 0000000..06c2a9e --- /dev/null +++ b/src/slides/2.html @@ -0,0 +1,4 @@ +
+

Other Title

+

Subtitle

+