Files
website/layouts/_shortcodes/figure.html
Akshay Kolli e240b99cb2
All checks were successful
Deploy Website / build-and-deploy (push) Successful in 1m44s
Initial website deployment
2026-07-02 00:28:25 -07:00

21 lines
677 B
HTML

{{ $id := .Get "id" | default (printf "figure-%d" .Ordinal) }}
{{ $src := .Get "src" }}
{{ $caption := .Get "caption" }}
{{ $alt := .Get "alt" | default $caption }}
{{ $figures := .Page.Scratch.Get "figures" | default dict }}
{{ $number := add (len $figures) 1 }}
{{ .Page.Scratch.SetInMap "figures" $id $number }}
<figure id="{{ $id }}" class="figure">
{{ with $src }}
<img src="{{ . | relURL }}" alt="{{ $alt }}">
{{ end }}
{{ if or $caption .Inner }}
<figcaption>
<span class="figure-label">Figure {{ $number }}.</span>
{{ with $caption }}{{ . | markdownify }}{{ else }}{{ .Inner | markdownify }}{{ end }}
</figcaption>
{{ end }}
</figure>