Add "content" attribute to slide shortcode

Points to a data template where markdown is contained. Makes it easy to reuse slides.
This commit is contained in:
dzello 2018-07-21 10:53:55 +02:00
parent c70aa5811e
commit 836c449d0c

View file

@ -1,9 +1,26 @@
{{ .Scratch.Set "slides" slice }}
{{ if trim .Inner "\n" }}
{{ .Scratch.Add "slides" .Inner }}
{{ end }}
{{ if .Get "content" }}
{{ $lookup := split (.Get "content") "." }}
{{ $html := index .Page.Site.Data (index $lookup 0) (index $lookup 1) | markdownify }}
{{ $slides := split $html "<hr />" }}
{{ $scratch := .Scratch }}
{{ range $slides }}
{{ $scratch.Add "slides" . }}
{{ end }}
{{ end }}
{{ $attributes := slice "background-color" "background-image" "background-size" "background-position" "background-repeat" "transition" "transition-speed" "background-iframe" "background-interactive" "background-video" "background-video-loop" "background-video-muted" }} {{ $attributes := slice "background-color" "background-image" "background-size" "background-position" "background-repeat" "transition" "transition-speed" "background-iframe" "background-interactive" "background-video" "background-video-loop" "background-video-muted" }}
{{ $params := . }} {{ $params := . }}
{{ range .Scratch.Get "slides" }}
<section data-noprocess <section data-noprocess
{{- range $attribute := $attributes -}} {{- range $attribute := $attributes -}}
{{- with $params.Get $attribute }} data-{{ $attribute | safeHTMLAttr }}="{{ . }}"{{ end -}} {{- with $params.Get $attribute }} data-{{ $attribute | safeHTMLAttr }}="{{ . }}"{{ end -}}
{{- end -}} {{- end -}}>
> {{ . | safeHTML }}
{{ .Inner }} </section>
</section> {{ end }}