mirror of
https://github.com/thegeeklab/hugo-geekdoc.git
synced 2024-11-05 04:40:40 +00:00
52 lines
1.7 KiB
HTML
52 lines
1.7 KiB
HTML
{{- $source := ($.Page.Resources.ByType "image").GetMatch (printf "%s" (.Get "name")) }}
|
|
{{- $customAlt := .Get "alt" }}
|
|
{{- $customSize := .Get "size" | lower }}
|
|
{{- $lazyLoad := default (default true $.Site.Params.GeekblogImageLazyLoading) (.Get "lazy") }}
|
|
|
|
{{- with $source }}
|
|
{{- $caption := default .Title $customAlt }}
|
|
|
|
{{- $profile := (.Fill "180x180 Center").Permalink }}
|
|
{{- $tiny := (.Resize "320x").Permalink }}
|
|
{{- $small := (.Resize "600x").Permalink }}
|
|
{{- $medium := (.Resize "1200x").Permalink }}
|
|
{{- $large := (.Resize "1800x").Permalink }}
|
|
|
|
{{- $size := dict "profile" $profile "tiny" $tiny "small" $small "medium" $medium "large" $large }}
|
|
|
|
|
|
<div class="flex justify-center">
|
|
<figure
|
|
class="gdoc-post__figure
|
|
{{- if eq $customSize "profile" }}{{ print " gdoc-post__figure--round" }}{{ end }}"
|
|
>
|
|
<a class="gdoc-markdown__link--raw" href="{{ .Permalink }}">
|
|
<picture>
|
|
<source
|
|
{{- with $customSize }}
|
|
srcset="{{ index $size $customSize }}"
|
|
{{- else }}
|
|
srcset="{{ $size.small }} 600w, {{ $size.medium }} 1200w" sizes="100vw"
|
|
{{- end }}
|
|
/>
|
|
<img
|
|
{{- if $lazyLoad }}{{ print " loading=\"lazy\"" | safeHTMLAttr }}{{- end }}
|
|
src="{{ $size.large }}"
|
|
alt="{{ $caption }}"
|
|
/>
|
|
</picture>
|
|
</a>
|
|
{{- if not (eq $customSize "profile") }}
|
|
{{- with $caption }}
|
|
<figcaption>
|
|
{{ . }}
|
|
{{- with $source.Params.credits }}
|
|
{{ printf " (%s)" . | $.Page.RenderString }}
|
|
{{- end }}
|
|
</figcaption>
|
|
{{- end }}
|
|
{{- end }}
|
|
</figure>
|
|
</div>
|
|
{{- end }}
|