mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
38 lines
1.8 KiB
HTML
38 lines
1.8 KiB
HTML
{{- $options := cond .IsNamedParams (.Get "src") (.Get 0) | dict "Src" -}}
|
|
{{- $options = cond .IsNamedParams (.Get "alt") (.Get 1) | .Page.RenderString | dict "Alt" | merge $options -}}
|
|
{{- $caption := cond .IsNamedParams (.Get "caption") (.Get 2) | .Page.RenderString -}}
|
|
{{- $options = dict "Caption" $caption | merge $options -}}
|
|
{{- $options = dict "Resources" .Page.Resources | merge $options -}}
|
|
{{- $optim := slice
|
|
(dict "Process" "resize 800x webp q75" "descriptor" "800w")
|
|
(dict "Process" "resize 1200x webp q75" "descriptor" "1200w")
|
|
(dict "Process" "resize 1600x webp q75" "descriptor" "1600w")
|
|
-}}
|
|
{{- $options = dict "OptimConfig" $optim | merge $options -}}
|
|
|
|
{{- if .IsNamedParams -}}
|
|
{{- $options = dict "Title" (.Get "title") | merge $options -}}
|
|
{{- $options = dict "Height" (.Get "height") | merge $options -}}
|
|
{{- $options = dict "Width" (.Get "width") | merge $options -}}
|
|
{{- $options = .Get "linked" | ne false | dict "Linked" | merge $options -}}
|
|
{{- $options = dict "Rel" (.Get "rel") | merge $options -}}
|
|
{{- $options = dict "Loading" (.Get "loading" | default "lazy") | merge $options -}}
|
|
{{- with (.Get "optimise") -}}{{- $options = dict "Optimise" . | merge $options -}}{{- end -}}
|
|
{{- with (.Get "cacheRemote") -}}{{- $options = dict "CacheRemote" . | merge $options -}}{{- end -}}
|
|
{{- else -}}
|
|
{{- $options = cond $caption true false | dict "Linked" | merge $options -}}
|
|
{{- end -}}
|
|
|
|
{{- $options = dict "Responsive" true | merge $options -}}
|
|
|
|
{{- with $caption -}}
|
|
<figure{{ with cond $.IsNamedParams ($.Get "class") "" }} class="{{ . }}"{{ end }}>
|
|
{{- partial "plugin/image.html" $options -}}
|
|
<figcaption class="image-caption">
|
|
{{- . | safeHTML -}}
|
|
</figcaption>
|
|
</figure>
|
|
{{- else -}}
|
|
{{- partial "plugin/image.html" $options -}}
|
|
{{- end -}}
|