figure.html 1.3 KB

123456789101112131415161718192021222324252627282930
  1. {{/* A copy of the built-in figure shortcode that properly runs the provided
  2. image src through relURL. */}}
  3. <figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
  4. {{- if .Get "link" -}}
  5. <a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
  6. {{- end }}
  7. <img src="{{ .Get "src" | relURL }}"
  8. {{- if or (.Get "alt") (.Get "caption") }}
  9. alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | $.Page.RenderString| plainify }}{{ end }}"
  10. {{- end -}}
  11. {{- with .Get "width" }} width="{{ . }}"{{ end -}}
  12. {{- with .Get "height" }} height="{{ . }}"{{ end -}}
  13. /> <!-- Closing img tag -->
  14. {{- if .Get "link" }}</a>{{ end -}}
  15. {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
  16. <figcaption>
  17. {{ with (.Get "title") -}}
  18. <h4>{{ . }}</h4>
  19. {{- end -}}
  20. {{- if or (.Get "caption") (.Get "attr") -}}<p>
  21. {{- .Get "caption" | $.Page.RenderString -}}
  22. {{- with .Get "attrlink" }}
  23. <a href="{{ . }}">
  24. {{- end -}}
  25. {{- .Get "attr" | $.Page.RenderString -}}
  26. {{- if .Get "attrlink" }}</a>{{ end }}</p>
  27. {{- end }}
  28. </figcaption>
  29. {{- end }}
  30. </figure>