Rewrite the figures/image template to use the new figures in the termlite theme

This commit is contained in:
Eryn Wells 2024-11-25 09:52:22 -08:00
parent 73aaf24f91
commit e3b93e5e0f
2 changed files with 20 additions and 31 deletions

View file

@ -17,35 +17,24 @@
{{ errorf "No images found for name(s) parameter" }}
{{- end -}}
{{ with $item := index $imgs 0 }}
<figure class="figure figure--{{ $item.ResourceType }}{{ with $class }} {{ . }}{{ end }}">
<div class="figure__container">
{{ if eq $item.ResourceType "image" }}
{{- $processedImage := $item -}}
{{- if $shouldResize -}}
{{ $processedImage = $item.Fit "1280x1280" }}
{{- end -}}
{{- $size := .Get "size" | default "full" -}}
{{- $altText := $item.Params.alt | default $item.Title -}}
<a href="{{ $item.RelPermalink }}">
<img src="{{ $processedImage.RelPermalink }}"
{{- with $altText }} alt="{{ . }}"{{- end }}
{{- with $item.Title }} title="{{ . }}"{{- end }}>
</a>
{{ else if eq $item.ResourceType "video" }}
<video controls width="100%">
<source src="{{ $item.RelPermalink }}" type="{{ $item.MediaType.Type }}">
</video>
{{- end }}
</div>
{{ if $shouldShowTitle -}}
{{- with $item -}}
{{- if gt (len .Title) 0 -}}
<figcaption>{{ .Title | markdownify }}</figcaption>
{{- end -}}
{{- end -}}
{{- end }}
</figure>
{{ else }}
{{ errorf "Found nil in items list for %s" $.Page.Permalink }}
{{ if in (slice "full" "main") $size }}
{{
partial "page/figures/fullwidth.html" (dict
"page" $.Page
"name" (.Get "name")
"size" $size
"shouldShowTitle" (.Get "shouldShowTitle" | default true)
)
}}
{{ else if eq $size "small" }}
{{
partial "page/figures/small.html" (dict
"page" $.Page
"name" (.Get "name")
"size" $size
"shouldShowTitle" (.Get "shouldShowTitle" | default true)
)
}}
{{ end }}

@ -1 +1 @@
Subproject commit b7ae6211ce477835ffbd0da7ea958bb4a4d5c8e7
Subproject commit 502aa408d9775d73c1bd75b199897ddbd71e3e28