hugo-theme-hyde-hyde/layouts/shortcodes/fig.html
Huy Tran 8e972ea83f To match the newly added counter for figures
This change revises the shortcode `fig` to match with the newly added
counter

Revises `fig.html` shortcode to match the newly added counter
2018-07-24 10:03:34 +10:00

22 lines
No EOL
796 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"}}