www.byjp.me/layouts/shortcodes/figure.html
JP Hastings-Spital dc9d1021cf Improve Political compass
- Ensures SVGs in "figure" shortcodes are imported, not referenced (so `currentColor` can work)
- Ensures SVGs aren't undersized when in the document
- Replaces the Inward compass with my own representation of it that works in dark & light modes
2024-09-19 08:55:40 +01:00

29 lines
No EOL
1.2 KiB
HTML

<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{- if .Get "link" -}}
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- end }}
{{ if eq (path.Ext (.Get "src")) ".svg" }}
{{ readFile (path.Join $.Page.File.Dir (.Get "src")) | safeHTML }}
{{ else }}
<img src="{{ path.Join $.Page.RelPermalink (.Get "src") }}"
{{- if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}}
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
/>
{{ end }}
{{- if .Get "link" }}</a>{{ end -}}
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
<figcaption>
{{- if or (.Get "caption") (.Get "attr") -}}<p>
{{- .Get "caption" | markdownify -}}
{{- with .Get "attrlink" }}
<a href="{{ . }}">
{{- end -}}
{{- .Get "attr" | markdownify -}}
{{- if .Get "attrlink" }}</a>{{ end }}</p>
{{- end }}
</figcaption>
{{- end }}
</figure>