Add a param to specify additional Reveal.js plugins to be loaded

This commit is contained in:
dzello
2019-03-16 23:59:21 +01:00
parent 4bbefde063
commit 485401ddca
2 changed files with 9 additions and 4 deletions
+1
View File
@@ -319,6 +319,7 @@ Customize the Reveal.js presentation by setting these values in `config.toml` or
- `reveal_hugo.highlight_theme`: The [highlight.js](https://highlightjs.org/) theme used; defaults to "default"
- `reveal_hugo.reveal_cdn`: The location to load Reveal.js files from; defaults to the `reveal-js` folder in the static directory to support offline development. To load from a CDN instead, set this value to `https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.7.0` or whatever CDN you prefer.
- `reveal_hugo.highlight_cdn`: The location to load highlight.js files from; defaults to to the `highlight-js` folder in the static directory to support offline development. To load from a CDN instead, set this value to `https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0` or whatever CDN you prefer.
- `reveal_hugo.plugins`: An array of additional Reveal.js plugins to load, e.g. `["plugin/gallery/gallery.plugin.js"]`. The appropriate files will need to have been copied into the `static` directory. CDN loading is not supported. The plugins included by default are markdown, highlight.js, notes and zoom.
This is how parameters will look in your `config.toml`:
+8 -4
View File
@@ -18,12 +18,16 @@
<script src="{{ printf "%s/js/reveal.js" $reveal_location | relURL }}"></script>
<!-- load Reveal.js plugins -->
<script type="text/javascript" src="{{ printf "%s/lib/js/classList.js" $reveal_location | relURL }}"></script>
<script type="text/javascript" src="{{ printf "%s/plugin/markdown/marked.js" $reveal_location | relURL }}"></script>
<script type="text/javascript" src="{{ printf "%s/plugin/markdown/markdown.js" $reveal_location | relURL }}"></script>
<script type="text/javascript" src="{{ printf "%s/plugin/highlight/highlight.js" $reveal_location | relURL }}"></script>
<script type="text/javascript" src="{{ printf "%s/plugin/zoom-js/zoom.js" $reveal_location | relURL }}"></script>
{{ $default_plugins := slice "plugin/markdown/marked.js" "plugin/markdown/markdown.js" "plugin/highlight/highlight.js" "plugin/zoom-js/zoom.js" }}
{{ range $default_plugins }}
<script type="text/javascript" src="{{ printf "%s/%s" $reveal_location . | relURL }}"></script>
{{ end }}
<!-- always use local version of the notes plugin since HTML file it requires isn't on CDN -->
<script type="text/javascript" src="{{ "reveal-js/plugin/notes/notes.js" | relURL }}"></script>
<!-- load custom plugins locally only (not CDN since many plugins won't exist there) -->
{{ range $.Param "reveal_hugo.plugins" }}
<script type="text/javascript" src="{{ . | relURL }}"></script>
{{ end }}
<script type="text/javascript">
// polyfill needed for IE11 and below
if (typeof Object.assign != 'function') {