figure.html 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. <figure{{ if or (.Get "class") (eq (.Get "align") "center") }} class="
  2. {{- if eq (.Get "align") "center" }}align-center {{ end }}
  3. {{- with .Get "class" }}{{ . }}{{- end }}"
  4. {{- end -}}>
  5. {{- if .Get "link" -}}
  6. <a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
  7. {{- end }}
  8. <img loading="lazy" src="{{ .Get "src" }}{{- if eq (.Get "align") "center" }}#center{{- end }}"
  9. {{- if or (.Get "alt") (.Get "caption") }}
  10. alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
  11. {{- end -}}
  12. {{- with .Get "width" }} width="{{ . }}"{{ end -}}
  13. {{- with .Get "height" }} height="{{ . }}"{{ end -}}
  14. /> <!-- Closing img tag -->
  15. {{- if .Get "link" }}</a>{{ end -}}
  16. {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
  17. <figcaption>
  18. {{ with (.Get "title") -}}
  19. {{ . }}
  20. {{- end -}}
  21. {{- if or (.Get "caption") (.Get "attr") -}}<p>
  22. {{- .Get "caption" | markdownify -}}
  23. {{- with .Get "attrlink" }}
  24. <a href="{{ . }}">
  25. {{- end -}}
  26. {{- .Get "attr" | markdownify -}}
  27. {{- if .Get "attrlink" }}</a>{{ end }}</p>
  28. {{- end }}
  29. </figcaption>
  30. {{- end }}
  31. </figure>