first commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<p>$${{- .Inner | safeHTML }}$$</p>
|
||||
{{ .Page.Store.Set "hasMath" true -}}
|
||||
@@ -0,0 +1,4 @@
|
||||
<div class="mermaid">
|
||||
{{- .Inner | safeHTML }}
|
||||
</div>
|
||||
{{ .Page.Store.Set "hasMermaid" true }}
|
||||
53
themes/reveal-hugo/layouts/_default/baseof.reveal.html
Normal file
53
themes/reveal-hugo/layouts/_default/baseof.reveal.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{{ partial "layout/head" . -}}
|
||||
{{ partial "layout/theme" . -}}
|
||||
{{ $plugins := partial "internal/plugins" . -}}
|
||||
{{- range $plugins }}
|
||||
{{- with .css }}
|
||||
|
||||
<link rel="stylesheet" href="{{ . | relURL }}"> {{- end -}}
|
||||
{{ end -}}
|
||||
<!-- To insert markup before the closing head tag for all presentations,
|
||||
create layouts/partials/reveal-hugo/head.html -->
|
||||
{{- partial "reveal-hugo/head" . -}}
|
||||
<!-- To insert markup at the end of the head tag for a specific presentation,
|
||||
create layouts/partials/{section}/reveal-hugo/head.html -->
|
||||
{{- $sectionHeadPartial := printf "%s/reveal-hugo/head" (.Page.Section | default "home") -}}
|
||||
{{- if fileExists (printf "layouts/partials/%s.html" $sectionHeadPartial) -}}{{ partial $sectionHeadPartial . }}{{- end }}
|
||||
</head>
|
||||
<body>
|
||||
{{ if .Param "logo.src" }}
|
||||
<style>
|
||||
#logo {
|
||||
position: absolute;
|
||||
top: {{ if .Param "logo.top"}}{{ .Param "logo.top" }}{{ else if .Param "logo.diag" }}{{ .Param "logo.diag" }}{{ else }}1%{{ end }};
|
||||
left: {{ if .Param "logo.top"}}{{ .Param "logo.left" }}{{ else if .Param "logo.diag" }}{{ .Param "logo.diag" }}{{ else }}1%{{ end }};
|
||||
width: {{ if .Param "logo.width"}}{{ .Param "logo.width" }}{{ else }}15%{{ end }};
|
||||
}
|
||||
</style>
|
||||
<img id="logo" src="{{ .Param "logo.src" }}" alt="{{ .Param "logo.alt" }}">
|
||||
{{ end }}
|
||||
<div class="reveal">
|
||||
<div class="slides">
|
||||
{{- block "main" . -}}{{- end -}}
|
||||
</div>
|
||||
<!-- To insert markup at the end of the .reveal tag for all presentations,
|
||||
create layouts/partials/reveal-hugo/end.html -->
|
||||
{{- partial "reveal-hugo/end" . -}}
|
||||
<!-- To insert markup at the end of the .reveal tag for a specific presentation,
|
||||
create layouts/partials/{section}/reveal-hugo/end.html -->
|
||||
{{- $sectionHeadPartial := printf "%s/reveal-hugo/end" (.Page.Section | default "home") -}}
|
||||
{{- if fileExists (printf "layouts/partials/%s.html" $sectionHeadPartial) -}}{{ partial $sectionHeadPartial . }}{{- end }}
|
||||
</div>
|
||||
{{- partial "layout/javascript" . }}
|
||||
<!-- To insert markup before the closing body tag for all presentations,
|
||||
create layouts/partials/reveal-hugo/body.html -->
|
||||
{{- partial "reveal-hugo/body" . }}
|
||||
<!-- To insert markup at the end of the head tag for a specific presentation,
|
||||
create layouts/partials/{section}/reveal-hugo/body.html -->
|
||||
{{- $sectionBodyPartial := printf "%s/reveal-hugo/body" (.Page.Section | default "home") -}}
|
||||
{{- if fileExists (printf "layouts/partials/%s.html" $sectionBodyPartial) -}}{{ partial $sectionBodyPartial . }}{{- end }}
|
||||
</body>
|
||||
</html>
|
||||
4
themes/reveal-hugo/layouts/_default/bundle.reveal.html
Normal file
4
themes/reveal-hugo/layouts/_default/bundle.reveal.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ define "main" }}
|
||||
{{ partial "reveal-hugo/slides" (slice .Page) }}
|
||||
{{ partial "reveal-hugo/slides" (.Resources.ByType "page") }}
|
||||
{{ end }}
|
||||
4
themes/reveal-hugo/layouts/_default/index.reveal.html
Normal file
4
themes/reveal-hugo/layouts/_default/index.reveal.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ define "main" }}
|
||||
{{ partial "reveal-hugo/slides" (slice .Page) }}
|
||||
{{ partial "reveal-hugo/slides" (where .Site.RegularPages "Type" "home") }}
|
||||
{{ end }}
|
||||
0
themes/reveal-hugo/layouts/_default/list.html
Normal file
0
themes/reveal-hugo/layouts/_default/list.html
Normal file
4
themes/reveal-hugo/layouts/_default/list.reveal.html
Normal file
4
themes/reveal-hugo/layouts/_default/list.reveal.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ define "main" }}
|
||||
{{ partial "reveal-hugo/slides" (slice .Page) }}
|
||||
{{ partial "reveal-hugo/slides" (where .Pages "Kind" "page") }}
|
||||
{{ end }}
|
||||
0
themes/reveal-hugo/layouts/_default/single.html
Normal file
0
themes/reveal-hugo/layouts/_default/single.html
Normal file
@@ -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 }}
|
||||
7
themes/reveal-hugo/layouts/partials/layout/head.html
Normal file
7
themes/reveal-hugo/layouts/partials/layout/head.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>{{ or .Page.Title .Site.Title }}</title>
|
||||
{{ with $.Param "description" }}<meta name="description" content="{{ . }}">{{ end }}
|
||||
{{ with .Site.Author.name }}<meta name="author" content="{{ . }}">{{ end }}
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
115
themes/reveal-hugo/layouts/partials/layout/javascript.html
Normal file
115
themes/reveal-hugo/layouts/partials/layout/javascript.html
Normal file
@@ -0,0 +1,115 @@
|
||||
<!-- polyfill needed for IE11 and below -->
|
||||
<script type="text/javascript" src={{ "reveal-hugo/object-assign.js" | relURL }}></script>
|
||||
<!-- Printing and PDF exports -->
|
||||
<!-- use Hugo to create the right path for the print stylesheet, then conditionally include it -->
|
||||
{{- $reveal_location := $.Param "reveal_hugo.reveal_cdn" | default "reveal-js" -}}
|
||||
|
||||
<!-- load Reveal.js javascripts -->
|
||||
<script src="{{ printf "%s/dist/reveal.js" $reveal_location | relURL }}"></script>
|
||||
|
||||
<!-- load default and user plugins -->
|
||||
{{- $plugins := partial "internal/plugins" . -}}
|
||||
{{ $pluginNames := slice }}
|
||||
{{- range $plugins }}
|
||||
<script type="text/javascript" src="{{ .source | relURL }}"></script>
|
||||
{{ $pluginNames = $pluginNames | append .name }}
|
||||
{{- end -}}
|
||||
|
||||
<!-- initialize Reveal.js -->
|
||||
<script type="text/javascript">
|
||||
// Hugo lowercases all params and Reveal.js needs camelcase
|
||||
// So params in Hugo must be stored in snakecase and we camelize them here
|
||||
function camelize(map) {
|
||||
if (map) {
|
||||
Object.keys(map).forEach(function(k) {
|
||||
newK = k.replace(/(\_\w)/g, function(m) { return m[1].toUpperCase() });
|
||||
if (newK != k) {
|
||||
map[newK] = map[k];
|
||||
delete map[k];
|
||||
}
|
||||
});
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
var revealHugoDefaults = { center: true, controls: true, history: true, progress: true, transition: "slide" };
|
||||
var revealHugoSiteParams = {{ jsonify (partial "internal/func/cleanParams" .Site.Params.reveal_hugo) | safeJS }};
|
||||
var revealHugoPageParams = {{ jsonify (partial "internal/func/cleanParams" .Page.Params.reveal_hugo) | safeJS }};
|
||||
|
||||
var revealHugoPlugins = {
|
||||
// generate an array of javascript objects
|
||||
plugins: {{ (printf "%s" (replace ( jsonify ( $pluginNames ) ) "\"" "")) | safeJS }}
|
||||
};
|
||||
|
||||
// See all options - https://github.com/hakimel/reveal.js#configuration
|
||||
var options = Object.assign({},
|
||||
camelize(revealHugoDefaults),
|
||||
camelize(revealHugoSiteParams),
|
||||
camelize(revealHugoPageParams),
|
||||
camelize(revealHugoPlugins));
|
||||
|
||||
Reveal.initialize(options);
|
||||
</script>
|
||||
|
||||
{{/* check if we need to load mermaid and its render trick.
|
||||
mermaid is not rendered correctly in reveal if we don't hook
|
||||
to the slidechanged event. (mermaid viewBox element has wrong sizes).
|
||||
manage hot-reload by using the reveal ready event.
|
||||
*/}}
|
||||
{{ $hasMermaid := false }}
|
||||
{{ $hasMath := false }}
|
||||
{{ range .Site.AllPages }}
|
||||
{{ if .Store.Get "hasMermaid" }}
|
||||
{{ $hasMermaid = true }}
|
||||
{{ end }}
|
||||
{{ if or .Params.math (.Store.Get "hasMath") }}
|
||||
{{ $hasMath = true }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $hasMermaid }}
|
||||
{{ $mermaidSrc := resources.GetRemote "https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js" }}
|
||||
<script type="text/javascript" src="{{ $mermaidSrc.RelPermalink }}"></script>
|
||||
<script type="text/javascript">
|
||||
mermaid.initialize({startOnLoad: false});
|
||||
let render = (event) => {
|
||||
let mermaidElems = event.currentSlide.querySelectorAll('.mermaid');
|
||||
if (!mermaidElems.length){
|
||||
return
|
||||
}
|
||||
mermaidElems.forEach(mermaidElem => {
|
||||
let processed = mermaidElem.getAttribute('data-processed');
|
||||
if (!processed){
|
||||
// https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344
|
||||
mermaid.init(undefined, mermaidElem);
|
||||
}
|
||||
});
|
||||
};
|
||||
// support current page reload with possible mermaid element
|
||||
render({currentSlide: Reveal.getCurrentSlide()});
|
||||
|
||||
Reveal.on('slidechanged', render);
|
||||
Reveal.on('ready', render);
|
||||
</script>
|
||||
{{ end }}
|
||||
|
||||
{{ if $hasMath }}
|
||||
<script>
|
||||
MathJax = {
|
||||
tex: {
|
||||
inlineMath: [['$', '$'], ['\\(', '\\)']]
|
||||
},
|
||||
svg: {
|
||||
fontCache: 'global'
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
{{ $mathjaxSrc := resources.GetRemote "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js" }}
|
||||
<script type="text/javascript" id="MathJax-script" async src="{{ $mathjaxSrc.RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
|
||||
{{- $custom_js := $.Param "reveal_hugo.custom_js" -}}
|
||||
{{- if $custom_js -}}
|
||||
<script type="text/javascript" src="{{ $custom_js | relURL }}"></script>
|
||||
{{- end -}}
|
||||
28
themes/reveal-hugo/layouts/partials/layout/theme.html
Normal file
28
themes/reveal-hugo/layouts/partials/layout/theme.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!-- Theme used for presentation -->
|
||||
{{- $reveal_location := $.Param "reveal_hugo.reveal_cdn" | default "reveal-js" -}}
|
||||
{{- $highlight_location := $.Param "reveal_hugo.highlight_cdn" | default "highlight-js" -}}
|
||||
{{- $custom_theme := $.Param "reveal_hugo.custom_theme" -}}
|
||||
<link rel="stylesheet" href="{{ printf "%s/dist/reset.css" $reveal_location | relURL }}">
|
||||
<link rel="stylesheet" href="{{ printf "%s/dist/reveal.css" $reveal_location | relURL }}">
|
||||
{{- $custom_theme := $.Param "reveal_hugo.custom_theme" -}}
|
||||
{{- if $custom_theme -}}
|
||||
{{- $custom_theme_options := $.Param "reveal_hugo.custom_theme_options" | default dict -}}
|
||||
{{- if $.Param "reveal_hugo.custom_theme_compile" -}}
|
||||
{{ $asset := resources.Get $custom_theme | resources.ExecuteAsTemplate "_.scss" . | toCSS $custom_theme_options | minify | fingerprint }}
|
||||
<link rel="stylesheet" href="{{ $asset.Permalink | relURL }}" id="theme">
|
||||
{{- else -}}
|
||||
<link rel="stylesheet" href="{{ $custom_theme | relURL }}" id="theme">
|
||||
{{- end -}}
|
||||
{{ else -}}
|
||||
{{- $theme := $.Param "reveal_hugo.theme" | default "black" -}}
|
||||
<link rel="stylesheet" href="{{ printf "%s/dist/theme/%s.css" $reveal_location $theme | relURL }}" id="theme">
|
||||
{{ end -}}
|
||||
{{ if $.Param "reveal_hugo.load_default_plugins" | default true -}}
|
||||
<!-- Theme used for syntax highlighting of code -->
|
||||
{{- $highlight_theme := $.Param "reveal_hugo.highlight_theme" | default "default" -}}
|
||||
<link rel="stylesheet" href="{{ printf "%s/%s.min.css" $highlight_location $highlight_theme | relURL }}">
|
||||
{{- end }}
|
||||
{{- $custom_css := $.Param "reveal_hugo.custom_css" -}}
|
||||
{{- if $custom_css -}}
|
||||
<link rel="stylesheet" href="{{ $custom_css | relURL }}" id="custom_css">
|
||||
{{- end -}}
|
||||
@@ -0,0 +1 @@
|
||||
<!-- override this partial to add content before the body tag closes -->
|
||||
1
themes/reveal-hugo/layouts/partials/reveal-hugo/end.html
Normal file
1
themes/reveal-hugo/layouts/partials/reveal-hugo/end.html
Normal file
@@ -0,0 +1 @@
|
||||
<!-- override this partial to add content before the .reveal tag closes -->
|
||||
@@ -0,0 +1 @@
|
||||
<!-- override this partial to add content before the head tag closes -->
|
||||
26
themes/reveal-hugo/layouts/partials/reveal-hugo/slides.html
Normal file
26
themes/reveal-hugo/layouts/partials/reveal-hugo/slides.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<!-- Use the array of pages passed as a param -->
|
||||
{{ range . -}}
|
||||
<!-- Don't process empty content files -->
|
||||
{{- if .Content -}}
|
||||
<!-- Remove the <hr /> tag generated by blackfriday for footnotes -->
|
||||
{{- $content := replace .Content "<div class=\"footnotes\">\n\n<hr />" "<div class=\"footnotes\">" -}}
|
||||
<!-- <code> blocks processed by Hugo's highlighter have a data-lang attribute. For those, we disable -->
|
||||
<!-- highlight.js by changing the language class to "nohighlight", and adding "data-noescape". -->
|
||||
{{- $content := replaceRE `<code class="language-\w+"\s+data-lang="\w+"` `<code class="nohighlight" data-noescape` $content -}}
|
||||
<!-- enable Highlight.js line numbers when the markdown code block language selection is followed by "{}" e.g. ```js{} -->
|
||||
{{- $content := replaceRE `(<code class="language-\w+){}(">)` `$1" data-line-numbers>` $content -}}
|
||||
<!-- enable Highlight.js line highlights when the language selection is followed by "{<line numbers>}" e.g. ```js{1,5-7} -->
|
||||
{{- $content := replaceRE `(<code class="language-\w+){(\S+)}(">)` `$1" data-line-numbers="$2">` $content -}}
|
||||
<!-- Support both <hr /> (blackfriday) and <hr> (mmark) -->
|
||||
{{- $content := replace $content "<hr>" "<hr />" -}}
|
||||
<!-- Split the processed content by <hr /> tag -->
|
||||
{{- range (split $content "<hr />") -}}
|
||||
<!-- Only wrap in <section> tag if not already wrapped by shortcode -->
|
||||
{{- if not (in . "data-noprocess") -}}
|
||||
<section>
|
||||
{{- end -}}
|
||||
{{- . | safeHTML -}}
|
||||
</section>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
4
themes/reveal-hugo/layouts/shortcodes/frag.html
Normal file
4
themes/reveal-hugo/layouts/shortcodes/frag.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<span class='fragment {{ .Get "class" }}'
|
||||
{{ with .Get "index" }}data-fragment-index='{{ . }}'{{ end }}>
|
||||
{{ .Get "c" }}
|
||||
</span>
|
||||
4
themes/reveal-hugo/layouts/shortcodes/fragment.html
Normal file
4
themes/reveal-hugo/layouts/shortcodes/fragment.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{{/* Render .Inner before processing the shortcode. */}}
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
<span class='fragment {{ .Get "class" }}' {{ with .Get "index" }}data-fragment-index='{{ . }}'{{ end }}>{{ .Inner }}</span>
|
||||
|
||||
8
themes/reveal-hugo/layouts/shortcodes/markdown.html
Normal file
8
themes/reveal-hugo/layouts/shortcodes/markdown.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<section data-noprocess data-markdown
|
||||
data-separator="^\r?\n---\r?\n$"
|
||||
data-separator-vertical="^\r?\n------\r?\n$"
|
||||
data-separator-notes="notes?:">
|
||||
<script type="text/template">
|
||||
{{ .Inner }}
|
||||
</script>
|
||||
</section>
|
||||
31
themes/reveal-hugo/layouts/shortcodes/math.html
Normal file
31
themes/reveal-hugo/layouts/shortcodes/math.html
Normal file
@@ -0,0 +1,31 @@
|
||||
{{ $math := "" -}}
|
||||
|
||||
{{ with .Get "inline" -}}
|
||||
{{/* Error checking */ -}}
|
||||
{{ if $.Inner -}}
|
||||
{{ errorf "%s: shortcode math with parameter 'inline' must not have inner content declared" $.Page.File.Path -}}
|
||||
{{ end -}}
|
||||
{{ if ne ( printf "%T" . ) "string" -}}
|
||||
{{ errorf "%s: shortcode math: parameter 'inline' must be a string" $.Page.File.Path -}}
|
||||
{{ end -}}
|
||||
{{ $math = . -}}
|
||||
{{ else -}}
|
||||
{{ with $.Get 0 -}}
|
||||
{{ if $.Inner -}}
|
||||
{{ errorf "%s: shortcode math for inline content must not have inner content declared" $.Page.File.Path -}}
|
||||
{{ end -}}
|
||||
{{ $math = $.Get 0 -}}
|
||||
{{ else }}
|
||||
{{ if .IsNamedParams}}
|
||||
{{ errorf "%s: shortcode math: Invalid named parameter(s) (%v) detected. Only named parameter 'inline' is allowed." $.Page.File.Path .Params -}}
|
||||
{{ end }}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ if eq $math "" -}}
|
||||
<p>$${{- .Inner | safeHTML }}$$</p>
|
||||
{{ else -}}
|
||||
${{- $math | safeHTML }}$
|
||||
{{ end -}}
|
||||
|
||||
{{ .Page.Store.Set "hasMath" true }}
|
||||
4
themes/reveal-hugo/layouts/shortcodes/mermaid.html
Normal file
4
themes/reveal-hugo/layouts/shortcodes/mermaid.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="mermaid">
|
||||
{{- .Inner | safeHTML }}
|
||||
</div>
|
||||
{{ .Page.Store.Set "hasMermaid" true }}
|
||||
4
themes/reveal-hugo/layouts/shortcodes/note.html
Normal file
4
themes/reveal-hugo/layouts/shortcodes/note.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{{/* Markdown is not rendered inside <aside> tags! So we use the following */}}
|
||||
{{/* config which causes .Inner to be rendered before processing the shortcode. */}}
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
<aside class="notes">{{ .Inner }}</aside>
|
||||
5
themes/reveal-hugo/layouts/shortcodes/section.html
Normal file
5
themes/reveal-hugo/layouts/shortcodes/section.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{/* Render .Inner before processing the shortcode. */}}
|
||||
{{ $_hugo_config := `{ "version": 1 }` }}
|
||||
<section data-shortcode-section>
|
||||
{{ .Inner }}
|
||||
</section>
|
||||
63
themes/reveal-hugo/layouts/shortcodes/slide.html
Normal file
63
themes/reveal-hugo/layouts/shortcodes/slide.html
Normal file
@@ -0,0 +1,63 @@
|
||||
{{- $scratch := .Scratch -}}
|
||||
{{- $scratch.Set "slides" slice -}}
|
||||
{{- $content := .Get "content" -}}
|
||||
{{- if $content -}}
|
||||
{{- $lookup := split $content "." }}
|
||||
{{ $markdownContent := .Page.Site.Data }}
|
||||
{{- range $dataPath := $lookup -}}
|
||||
{{- $markdownContent = index $markdownContent $dataPath -}}
|
||||
{{- end -}}
|
||||
{{- $html := $markdownContent | markdownify -}}
|
||||
{{- $html := replace $html "<hr>" "<hr />" -}}
|
||||
{{- $slides := split $html "<hr />" -}}
|
||||
{{- range $slides -}}
|
||||
{{- $scratch.Add "slides" . -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $scratch.Add "slides" "" -}}
|
||||
{{- end -}}
|
||||
{{- $params := . -}}
|
||||
{{- $noPrefix := slice "id" "class" -}}
|
||||
{{- $noOutput := slice "content" "template" -}}
|
||||
{{- $template := $params.Get "template" -}}
|
||||
{{- if $template -}}
|
||||
{{- $scratch.Add "templateParams" slice -}}
|
||||
{{- with $.Site.Params.reveal_hugo.templates -}}
|
||||
{{- $scratch.Add "templateParams" . -}}
|
||||
{{- end -}}
|
||||
{{- if ne $.Page.File.LogicalName "_index.md" -}}
|
||||
{{- $scratch.Add "templateParams" ($.Site.GetPage $.Page.Section).Params.reveal_hugo.templates -}}
|
||||
{{- end -}}
|
||||
{{- with $.Page.Params.reveal_hugo.templates -}}
|
||||
{{- $scratch.Add "templateParams" . -}}
|
||||
{{- end -}}
|
||||
{{- $scratch.Add "templateParams" (slice $.Page.Params.reveal_hugo.templates) -}}
|
||||
{{- $templateParams := $scratch.Get "templateParams" }}
|
||||
{{- range $templateParams -}}
|
||||
{{- if (ne . nil) -}}
|
||||
{{- range $key, $value := (index . $template) -}}
|
||||
{{- $scratch.SetInMap "template" $key $value | safeHTMLAttr -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- range $sindex, $svalue := $scratch.Get "slides" }}
|
||||
<section data-noprocess data-shortcode-slide
|
||||
{{- if $template -}}
|
||||
{{- range $key, $value := ($scratch.Get "template") }}
|
||||
{{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }}
|
||||
{{ $attrName | safeHTMLAttr }}="{{ $value }}"
|
||||
{{- end }}
|
||||
data-template="{{ $template }}"
|
||||
{{- end -}}
|
||||
{{- range $key, $value := $.Params -}}
|
||||
{{- if not (in $noOutput $key) -}}
|
||||
{{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }}
|
||||
{{ $attrName | safeHTMLAttr }}="{{ $value }}"
|
||||
{{- end -}}
|
||||
{{- end -}}>
|
||||
{{ $svalue | safeHTML }}
|
||||
{{- if ne $sindex (sub (len ($scratch.Get "slides")) 1) -}}
|
||||
</section>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user