Overhaul figures

This commit is contained in:
Will Faught
2023-01-06 14:11:48 -08:00
parent fd81ccccd5
commit cf823d7d63
13 changed files with 624 additions and 148 deletions

View File

@@ -0,0 +1,38 @@
{{ $alt := .alt }}
{{ $class := .class }}
{{ $height := .height }}
{{ $loading := .loading | default "lazy" }}
{{ $method := .method }}
{{ $options := .options }}
{{ $page := .page }}
{{ $referrerpolicy := .referrerpolicy | default "no-referrer" }}
{{ $resource := .resource }}
{{ $src := .src }}
{{ $style := .style }}
{{ $title := .title }}
{{ $width := .width }}
{{ if not $resource }}
{{ $resource = partial "paige/func-resource.html" (dict
"page" $page
"url" $src
) }}
{{ end }}
{{ if and $method $options }}
{{ if eq $method "crop" }}
{{ $resource = $resource.Crop $options }}
{{ else if eq $method "fill" }}
{{ $resource = $resource.Fill $options }}
{{ else if eq $method "fit" }}
{{ $resource = $resource.Fit $options }}
{{ else if eq $method "resize" }}
{{ $resource = $resource.Resize $options }}
{{ else }}
{{ errorf "invalid method: %q" $method }}
{{ end }}
{{ end }}
{{ $src = ($resource | fingerprint).RelPermalink }}
<img {{ with $alt }} alt="{{ . }}" {{ end }} {{ with $class }} class="{{ . }}" {{ end }} {{ with $height }} height="{{ . }}" {{ end }} loading="{{ $loading }}" referrerpolicy="{{ $referrerpolicy }}" src="{{ $src }}" {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ with $title }} title="{{ . }}" {{ end }} {{ with $width }} width="{{ . }}" {{ end }}>