first commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
{{/* This function is meant to remove reveal-js unrelated initializers (like the
|
||||
plugins array)
|
||||
*/}}
|
||||
{{- $params := dict -}}
|
||||
{{- range $k, $v := . -}}
|
||||
{{ if not (in (slice "plugins") $k) }}
|
||||
{{ $params = merge $params (dict $k $v) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ return $params }}
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
{{ $plugin_path := "" }}
|
||||
{{/* try different sources of local plugin paths. They can be in the static dir,
|
||||
or the current content bundle. Setting the "verbatim" attribute to true overrides
|
||||
the heuristic.
|
||||
*/}}
|
||||
|
||||
{{ if .verbatim | default false }}
|
||||
{{/* take this path for face value */}}
|
||||
{{ $plugin_path = .path }}
|
||||
{{ else if or (fileExists .path) (fileExists (path.Join "static" .path)) }}
|
||||
{{/* file exists in content or static, use that */}}
|
||||
{{ $plugin_path = .path }}
|
||||
{{ else }}
|
||||
{{/* file exists on filesystem or in CDN use that */}}
|
||||
{{ $plugin_path = path.Join .reveal_location .path }}
|
||||
{{ end }}
|
||||
|
||||
{{ return $plugin_path }}
|
||||
70
themes/reveal-hugo/layouts/partials/internal/plugins.html
Normal file
70
themes/reveal-hugo/layouts/partials/internal/plugins.html
Normal file
@@ -0,0 +1,70 @@
|
||||
{{/* We want to construct a plugins slice of unique plugins. We start by taking the
|
||||
default plugins if they are enabled, then iterate on additional user defined
|
||||
plugins.
|
||||
|
||||
We support the legacy style of plugin paths (although this might break in reveal-js
|
||||
>= 4.0 - we might revisit this.)
|
||||
*/}}
|
||||
|
||||
{{/* Use a scratch dict to ensure unicity of plugins. This dict has an order key
|
||||
because the plugins need to be loaded in a specific order (i.e. markdown
|
||||
depends on marked)
|
||||
*/}}
|
||||
{{ $startOrder := 0}}
|
||||
{{ $plugins := newScratch }}
|
||||
{{ if $.Param "reveal_hugo.load_default_plugins" | default true }}
|
||||
{{ $plugins.SetInMap "plugins" "RevealMarkdown" (dict "name" "RevealMarkdown" "order" 1 "source" "plugin/markdown/markdown.js") }}
|
||||
{{ $plugins.SetInMap "plugins" "RevealHighlight" (dict "name" "RevealHighlight" "order" 2 "source" "plugin/highlight/highlight.js") }}
|
||||
{{ $plugins.SetInMap "plugins" "zoom" (dict "name" "RevealZoom" "order" 3 "source" "plugin/zoom/zoom.js") }}
|
||||
|
||||
<!-- always use local version of the notes plugin since HTML file it requires isn't on CDN -->
|
||||
{{ $plugins.SetInMap "plugins" "RevealNotes" (dict "name" "RevealNotes" "order" 4 "source" "reveal-js/plugin/notes/notes.js"
|
||||
"verbatim" true) }}
|
||||
{{ $startOrder = 5 }}
|
||||
{{ end }}
|
||||
|
||||
{{ $allPlugins := $.Site.Param "reveal_hugo.plugins" | default slice }}
|
||||
{{ $allPlugins = append $allPlugins ($.Page.Param "reveal_hugo.plugins" | default slice ) }}
|
||||
|
||||
{{/* load custom user plugins */}}
|
||||
{{ range $allPlugins }}
|
||||
{{ if reflect.IsMap . }}
|
||||
{{/* we already have a plugin definition object */}}
|
||||
{{ with .order }}
|
||||
{{ $startOrder = . }}
|
||||
{{ end }}
|
||||
{{ $name := print .name }}
|
||||
{{ $plugins.SetInMap "plugins" $name (merge . (dict "name" $name "order" $startOrder) )}}
|
||||
{{ else if reflect.IsSlice . }}
|
||||
{{ range . }}
|
||||
{{/* convert from old plugin path to new plugin object format */}}
|
||||
{{ $name := path.BaseName .}}
|
||||
{{ $plugins.SetInMap "plugins" $name (dict "name" $name "source" . "order" $startOrder) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ $name := path.BaseName .}}
|
||||
{{ $plugins.SetInMap "plugins" $name (dict "name" $name "source" . "order" $startOrder) }}
|
||||
{{ end }}
|
||||
|
||||
{{ $startOrder = add $startOrder 1 }}
|
||||
{{ end }}
|
||||
|
||||
{{ $revealLoc := dict "reveal_location" ($.Param "reveal_hugo.reveal_cdn" | default "reveal-js") }}
|
||||
{{ $normalizedPlugins := slice }}
|
||||
|
||||
{{ range $plugin := (sort ($plugins.Get "plugins") "order") }}
|
||||
{{ $normalizedPlugin := $plugin }}
|
||||
|
||||
{{ with $plugin.css }}
|
||||
{{ $normalizedCssPath := partial "internal/func/normalizePath" (merge $plugin (dict "path" . ) $revealLoc ) }}
|
||||
{{ $normalizedPlugin = merge $normalizedPlugin (dict "css" $normalizedCssPath)}}
|
||||
{{ end }}
|
||||
{{ with $plugin.source }}
|
||||
{{ $normalizedSourcePath := partial "internal/func/normalizePath" (merge $plugin (dict "path" . ) $revealLoc ) }}
|
||||
{{ $normalizedPlugin = merge $normalizedPlugin (dict "source" $normalizedSourcePath)}}
|
||||
{{ end }}
|
||||
|
||||
{{ $normalizedPlugins = $normalizedPlugins | append $normalizedPlugin }}
|
||||
{{ end}}
|
||||
|
||||
{{ return $normalizedPlugins }}
|
||||
Reference in New Issue
Block a user