Add reveal_hugo.load_default_plugins option

This commit is contained in:
Kostas Chatzikokolakis
2019-09-11 13:40:22 +03:00
parent 68429eccc3
commit cd5ca462ac
3 changed files with 14 additions and 9 deletions
+2 -1
View File
@@ -329,7 +329,8 @@ 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.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.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.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. See here for a [big list of plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware) you can try. - `reveal_hugo.load_default_plugins`: If set to true (default), the plugins included by default are loaded. These are markdown, highlight.js, notes and zoom.
- `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. See here for a [big list of plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware) you can try.
This is how parameters will look in your `config.toml`: This is how parameters will look in your `config.toml`:
+7 -5
View File
@@ -47,12 +47,14 @@
</script> </script>
<!-- load Reveal.js plugins after Reveal.js is initialized --> <!-- load Reveal.js plugins after Reveal.js is initialized -->
<script type="text/javascript" src="{{ printf "%s/lib/js/classList.js" $reveal_location | relURL }}"></script> <script type="text/javascript" src="{{ printf "%s/lib/js/classList.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" }} {{ if $.Param "reveal_hugo.load_default_plugins" | default true }}
{{ range $default_plugins }} {{ $default_plugins := slice "plugin/markdown/marked.js" "plugin/markdown/markdown.js" "plugin/highlight/highlight.js" "plugin/zoom-js/zoom.js" }}
<script type="text/javascript" src="{{ printf "%s/%s" $reveal_location . | relURL }}"></script> {{ 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>
{{ end }} {{ 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) --> <!-- load custom plugins locally only (not CDN since many plugins won't exist there) -->
{{ range $.Param "reveal_hugo.plugins" }} {{ range $.Param "reveal_hugo.plugins" }}
<script type="text/javascript" src="{{ . | relURL }}"></script> <script type="text/javascript" src="{{ . | relURL }}"></script>
+5 -3
View File
@@ -16,6 +16,8 @@
{{- $theme := $.Param "reveal_hugo.theme" | default "black" -}} {{- $theme := $.Param "reveal_hugo.theme" | default "black" -}}
<link rel="stylesheet" href="{{ printf "%s/css/theme/%s.css" $reveal_location $theme | relURL }}" id="theme"> <link rel="stylesheet" href="{{ printf "%s/css/theme/%s.css" $reveal_location $theme | relURL }}" id="theme">
{{ end -}} {{ end -}}
<!-- Theme used for syntax highlighting of code --> {{ if $.Param "reveal_hugo.load_default_plugins" | default true -}}
{{- $highlight_theme := $.Param "reveal_hugo.highlight_theme" | default "default" -}} <!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="{{ printf "%s/%s.min.css" $highlight_location $highlight_theme | relURL }}"> {{- $highlight_theme := $.Param "reveal_hugo.highlight_theme" | default "default" -}}
<link rel="stylesheet" href="{{ printf "%s/%s.min.css" $highlight_location $highlight_theme | relURL }}">
{{- end }}