figure.html 841 B

1234567891011121314151617181920212223
  1. {{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get "img")) }}
  2. {{ $new := "" }}
  3. {{ if eq (.Get "command") "Fit" }}
  4. {{ $new = $original.Fit (.Get "options") }}
  5. {{ else if eq (.Get "command") "Fill" }}
  6. {{ $new = $original.Fill (.Get "options") }}
  7. {{ else if eq (.Get "command") "Resize" }}
  8. {{ $new = $original.Resize (.Get "options") }}
  9. {{ else if eq (.Get "command") "Original" }}
  10. {{ $new = $original }}
  11. {{ else }}
  12. {{ errorf "Invalid image processing command: Must be one of Fit, Fill, Resize, Original." }}
  13. {{ end }}
  14. <figure role="group" aria-describedby="caption-{{ (.Get "caption") | md5 }}">
  15. <a href="{{ $original.Permalink }}" class="img-link">
  16. <img src="{{ $new.Permalink }}">
  17. </a>
  18. <figcaption id="caption-{{ (.Get "caption") | md5 }}">
  19. {{ (.Get "caption") | markdownify }}
  20. </figcaption>
  21. </figure>