hugo-theme-hyde-hyde/layouts/shortcodes/fig.html

22 lines
796 B
HTML
Raw Normal View History

{{ $fig := newScratch }}
{{ if .Get "caption" }}
{{ $fig.Set "caption" (.Get "caption") }}
{{ else if .Get "alt" }}
{{ $fig.Set "caption" (.Get "alt") }}
{{ end }}
2018-07-21 07:08:41 +00:00
<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") }}
2018-07-21 07:08:41 +00:00
<figcaption>
<span class="img--caption">Figure {{ $.Page.Scratch.Get "fig" }}. {{ . }}</span>
2018-07-21 07:08:41 +00:00
</figcaption>
{{ end }}
</figure>
{{ .Page.Scratch.Add "fig" 1 }}
{{ $fig.Delete "caption"}}