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
This commit is contained in:
Huy Tran 2018-07-24 10:03:34 +10:00
parent 7e03bb3c64
commit 8e972ea83f

View file

@ -1,15 +1,22 @@
{{ $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" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}"{{ end }} />
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<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>
{{ with .Get "title" }}
<span class="img--caption">{{ . }}</span>
{{ end }}
{{ with (.Get "caption")}}
<span class="img--caption">{{ . }}</span>
{{ end }}
<span class="img--caption">Figure {{ $.Page.Scratch.Get "fig" }}. {{ . }}</span>
</figcaption>
{{ end }}
</figure>
{{ .Page.Scratch.Add "fig" 1 }}
{{ $fig.Delete "caption"}}