slide.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {{- $scratch := .Scratch -}}
  2. {{- $scratch.Set "slides" slice -}}
  3. {{- $content := .Get "content" -}}
  4. {{- if $content -}}
  5. {{- $lookup := split $content "." }}
  6. {{ $markdownContent := .Page.Site.Data }}
  7. {{- range $dataPath := $lookup -}}
  8. {{- $markdownContent = index $markdownContent $dataPath -}}
  9. {{- end -}}
  10. {{- $html := $markdownContent | markdownify -}}
  11. {{- $html := replace $html "<hr>" "<hr />" -}}
  12. {{- $slides := split $html "<hr />" -}}
  13. {{- range $slides -}}
  14. {{- $scratch.Add "slides" . -}}
  15. {{- end -}}
  16. {{- else -}}
  17. {{- $scratch.Add "slides" "" -}}
  18. {{- end -}}
  19. {{- $params := . -}}
  20. {{- $noPrefix := slice "id" "class" -}}
  21. {{- $noOutput := slice "content" "template" -}}
  22. {{- $template := $params.Get "template" -}}
  23. {{- if $template -}}
  24. {{- $scratch.Add "templateParams" slice -}}
  25. {{- with $.Site.Params.reveal_hugo.templates -}}
  26. {{- $scratch.Add "templateParams" . -}}
  27. {{- end -}}
  28. {{- if ne $.Page.File.LogicalName "_index.md" -}}
  29. {{- $scratch.Add "templateParams" ($.Site.GetPage $.Page.Section).Params.reveal_hugo.templates -}}
  30. {{- end -}}
  31. {{- with $.Page.Params.reveal_hugo.templates -}}
  32. {{- $scratch.Add "templateParams" . -}}
  33. {{- end -}}
  34. {{- $scratch.Add "templateParams" (slice $.Page.Params.reveal_hugo.templates) -}}
  35. {{- $templateParams := $scratch.Get "templateParams" }}
  36. {{- range $templateParams -}}
  37. {{- if (ne . nil) -}}
  38. {{- range $key, $value := (index . $template) -}}
  39. {{- $scratch.SetInMap "template" $key $value | safeHTMLAttr -}}
  40. {{- end -}}
  41. {{- end -}}
  42. {{- end -}}
  43. {{- end -}}
  44. {{- range $sindex, $svalue := $scratch.Get "slides" }}
  45. <section data-noprocess data-shortcode-slide
  46. {{- if $template -}}
  47. {{- range $key, $value := ($scratch.Get "template") }}
  48. {{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }}
  49. {{ $attrName | safeHTMLAttr }}="{{ $value }}"
  50. {{- end }}
  51. data-template="{{ $template }}"
  52. {{- end -}}
  53. {{- range $key, $value := $.Params -}}
  54. {{- if not (in $noOutput $key) -}}
  55. {{- $attrName := cond (in $noPrefix $key) $key (delimit (slice "data" $key) "-") }}
  56. {{ $attrName | safeHTMLAttr }}="{{ $value }}"
  57. {{- end -}}
  58. {{- end -}}>
  59. {{ $svalue | safeHTML }}
  60. {{- if ne $sindex (sub (len ($scratch.Get "slides")) 1) -}}
  61. </section>
  62. {{- end -}}
  63. {{- end -}}