hugo-theme-termlite/layouts/partials/page/figures/inline-image.html
Eryn Wells 7d56bd2f78 Inline image template
This is for embedding SVGs inline.
2025-01-04 10:12:29 -08:00

24 lines
723 B
HTML

{{- $image := .page.Resources.GetMatch .name -}}
{{ if not $image }}
{{ errorf "No images named '%s' found. %s " .name .page.Permalink }}
{{ end }}
{{ if ne $image.MediaType.SubType "svg" }}
{{ errorf "Only SVGs may be inlined. %s" $image.Permalink }}
{{ end }}
{{- $classes := slice "figure" "figure--image" "figure--inline-image" -}}
{{- if eq .size "main" -}}
{{ $classes = $classes | append "figure--main-column" }}
{{- end -}}
{{- with .class -}}
{{ $classes = $classes | append . }}
{{- end -}}
<figure class="{{ delimit $classes " " }}">
{{ $image.Content | safeHTML }}
{{ if .shouldShowTitle }}
{{ partial "page/figures/caption.html" (merge . (dict "resource" $image)) }}
{{ end }}
</figure>