cupper-hugo-theme/layouts/shortcodes/figureCupper.html

29 lines
884 B
HTML
Raw Permalink Normal View History

2019-02-13 20:54:04 +01:00
{{ $img := .Get "img" }}
{{ $caption := .Get "caption" }}
{{ $command := .Get "command" }}
{{ $options := .Get "options" }}
{{ $original := .Page.Resources.GetMatch (printf "*%s*" $img) }}
{{ $new := "" }}
2019-02-13 20:54:04 +01:00
{{ if eq $command "Fit" }}
{{ $new = $original.Fit $options }}
{{ else if eq $command "Fill" }}
{{ $new = $original.Fill $options }}
{{ else if eq $command "Resize" }}
{{ $new = $original.Resize $options }}
{{ else if eq $command "Original" }}
{{ $new = $original }}
{{ else }}
{{ errorf "Invalid image processing command: Must be one of Fit, Fill, Resize, Original." }}
{{ end }}
2019-02-13 20:54:04 +01:00
<figure role="group" aria-describedby="caption-{{ $caption | md5 }}">
2020-11-25 03:51:01 +01:00
<a href="{{ $original.RelPermalink }}" class="img-link">
<img src="{{ $new.RelPermalink }}">
</a>
2019-02-13 20:54:04 +01:00
<figcaption id="caption-{{ $caption | md5 }}">
{{ $caption | markdownify }}
2017-11-02 16:39:45 +01:00
</figcaption>
</figure>