aboutsummaryrefslogtreecommitdiff
path: root/themes
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2024-05-27 18:29:15 -0400
committerPaul Duncan <pabs@pablotron.org>2024-05-27 18:29:15 -0400
commitca9ae1f69a2bd531daad4395a712a24bca84f9b0 (patch)
treec313fa7f6e1f46b1fff9a3d68853b2e6bc20e041 /themes
parent267d399693e8885dbe2da33e846afe5bee8af27e (diff)
downloadpablotron.org-ca9ae1f69a2bd531daad4395a712a24bca84f9b0.tar.bz2
pablotron.org-ca9ae1f69a2bd531daad4395a712a24bca84f9b0.zip
add themes/hugo-pt2021/layouts/partials/carousel.html
Diffstat (limited to 'themes')
-rw-r--r--themes/hugo-pt2021/layouts/partials/carousel.html99
1 files changed, 99 insertions, 0 deletions
diff --git a/themes/hugo-pt2021/layouts/partials/carousel.html b/themes/hugo-pt2021/layouts/partials/carousel.html
new file mode 100644
index 0000000..1052160
--- /dev/null
+++ b/themes/hugo-pt2021/layouts/partials/carousel.html
@@ -0,0 +1,99 @@
+{{/*
+ notes:
+ - copied from pe-figure shortcode with MIME_TYPES removed
+ - should eventually allow for top and bottom carousels
+*/}}
+{{- if . -}}
+ <div class='columns'>
+ {{ range . }}
+ {{ $pic := . }}
+ {{- $tip := default $pic.link_tip $pic.tip -}}
+ <div class='column'>
+ {{- if $pic.link -}}
+ <a
+ href='{{ $pic.link }}'
+ title='{{ default $tip "View image" }}'
+ aria-label='{{ default $tip "View image" }}'
+ >
+ {{- end -}}
+ <figure
+ id='{{- $pic.id -}}'
+ class='{{- $pic.css -}}'
+ title='{{- default $pic.link_tip $pic.tip -}}'
+ >
+ <picture>
+ {{- if $pic.sources -}}
+ {{/* get source count */}}
+ {{- $num_sources := len $pic.sources -}}
+
+ {{/* render sources */}}
+ {{- range $x, $src := $pic.sources -}}
+ {{- $is_map := reflect.IsMap $src -}}
+
+ {{- if $is_map -}}
+ {{/* source is a map, reference keys */}}
+
+ {{- if (lt $x (sub $num_sources 1)) -}}
+ {{/* emit source tag */}}
+ <source
+ {{if $src.src}} src='{{- $src.src -}}'{{- end}}
+ {{if $src.srcset}} srcset='{{- $src.srcset -}}'{{- end}}
+ {{if $src.media}} media='{{- $src.media -}}'{{- end}}
+
+ {{if $src.type}}
+ type='{{- $src.type -}}'
+ {{else}}
+ {{/* get file extension */}}
+ {{- $ext := path.Ext $src.srcset -}}
+ {{- end}}
+
+ {{if (or $pic.tip $src.tip)}} title='{{- default $pic.tip $src.tip -}}'{{- end}}
+ {{if (or $pic.tip $src.tip)}} alt='{{- default $pic.tip $src.tip -}}'{{- end}}
+ />
+ {{- else -}}
+ {{/* emit img tag */}}
+ <img
+ {{if $src.src}} src='{{- $src.src -}}'{{- end}}
+ {{if $src.srcset}} srcset='{{- $src.srcset -}}'{{- end}}
+ {{if $src.css}} class='{{- $src.css -}}'{{- end}}
+ {{if $src.width}} width='{{- $src.width -}}'{{- end}}
+ {{if $src.height}} height='{{- $src.height -}}'{{- end}}
+
+ {{if (or $pic.tip $src.tip)}} alt='{{- default $pic.tip $src.tip -}}'{{- end}}
+ />
+ {{- end -}}
+ {{- else -}}
+ {{/* src is a string */}}
+
+ {{- if (lt $x (sub $num_sources 1)) -}}
+ {{/* emit source */}}
+
+ {{/* get file extension */}}
+ {{- $ext := path.Ext $src -}}
+
+ <source
+ srcset='{{- $src -}}'
+ />
+ {{- else -}}
+ {{/* emit img */}}
+ <img
+ src='{{- $src -}}'
+ {{if $pic.tip}} alt='{{- $pic.tip -}}'{{end}}
+ />
+ {{- end -}}
+ {{- end -}}
+ {{- end -}}
+ {{- end -}}
+ </picture>
+
+ <figcaption>
+ <p>{{- $pic.tip -}}</p>
+ </figcaption>
+ </figure>
+ {{- if $pic.link -}}
+ </a>
+ {{- end -}}
+ </div>
+ {{ end }}
+ </div>
+{{- end -}}