congo/layouts/shortcodes/figure.html

24 lines
910 B
HTML
Raw Normal View History

{{ $altText := .Get "alt" }}
{{ $caption := .Get "caption" }}
{{ $href := .Get "href" }}
{{ $class := .Get "class" }}
{{ with $.Page.Resources.GetMatch (.Get "src") }}
<figure {{ with $class }}class="{{ . }}"{{ end }}>
{{ with $href }}<a href="{{ . }}">{{ end }}
<img
class="my-0"
srcset="
{{ (.Resize "320x").RelPermalink }} 320w,
{{ (.Resize "635x").RelPermalink }} 635w,
{{ (.Resize "1024x").RelPermalink }} 1024w,
{{ (.Resize "1270x").RelPermalink }} 2x"
src="{{ (.Resize "635x").RelPermalink }}"
alt="{{ $altText }}"
/>
{{ if $href }}</a>{{ end }}
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
2021-08-11 05:28:33 +00:00
</figure>
{{ else }}
{{ errorf `[CONGO] Shortcode "figure" error in "%s": Resource "%s" not found. Check the path is correct or remove the shortcode.` .Page.Path (.Get "src") }}
2021-08-11 05:28:33 +00:00
{{ end }}