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

29 lines
878 B
HTML
Raw 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 }}">
<a href="{{ $original.Permalink }}" class="img-link">
<img src="{{ $new.Permalink }}">
</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>