hugo-theme-hyde-hyde/layouts/shortcodes/fig.html
2018-07-27 08:41:33 +10:00

21 lines
759 B
HTML

{{ $fig := newScratch }}
{{ if .Get "caption" }}
{{ $fig.Set "caption" (.Get "caption") }}
{{ else if .Get "alt" }}
{{ $fig.Set "caption" (.Get "alt") }}
{{ end }}
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
<img src="{{ .Get "src" }}"
{{ with $.Scratch.Get "caption" }}alt="{{ . }}"{{ end }}
{{ with .Get "align" }}align="{{ . }}"{{ end }}
{{ with .Get "width" }}width="{{ . }}"{{ end }} />
{{ with .Get "link"}}</a>{{ end }}
{{ with ($fig.Get "caption") }}
<figcaption>
<span class="img--caption">Figure {{ $.Page.Scratch.Get "fig" }}. {{ . }}</span>
</figcaption>
{{ end }}
</figure>
{{ .Page.Scratch.Add "fig" 1 }}
{{ $fig.Delete "caption"}}