Website Summary Files Commits Branches @commit @diff @stats
path: root / website / themes / reveal-hugo / layouts / shortcodes / slide.html
blob: 00163261aa6fa75f44d718c72cfde448cfcf4b6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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 -}}