From 836c449d0c54f2812c5c1fe3a02152cab08b10f5 Mon Sep 17 00:00:00 2001 From: dzello Date: Sat, 21 Jul 2018 10:53:55 +0200 Subject: [PATCH] Add "content" attribute to slide shortcode Points to a data template where markdown is contained. Makes it easy to reuse slides. --- layouts/shortcodes/slide.html | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/layouts/shortcodes/slide.html b/layouts/shortcodes/slide.html index 6a4fc79..70eea53 100644 --- a/layouts/shortcodes/slide.html +++ b/layouts/shortcodes/slide.html @@ -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 "
" }} + {{ $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" }} {{ $params := . }} +{{ range .Scratch.Get "slides" }}
-{{ .Inner }} -
\ No newline at end of file + {{- end -}}> + {{ . | safeHTML }} + +{{ end }}