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