jyosei-guide/layouts/shortcodes/figure.html

17 lines
677 B
HTML
Raw Normal View History

2022-08-07 17:23:16 +08:00
{{- $src := .Get "src" -}}
{{- $resource := .Page.Resources.Get $src -}}
{{- $title := .Get "title" | default $resource.Title -}}
2022-08-07 17:40:13 +08:00
{{- $hashtag := .Get "hashtag" | default (path.BaseName $src) | anchorize -}}
2022-08-07 17:23:16 +08:00
{{- $thumbnail := $resource.Resize "64x" | images.Filter (images.GaussianBlur 5) -}}
2022-08-07 17:40:13 +08:00
<figure class="image" id="{{ $hashtag }}">
2022-08-07 17:23:16 +08:00
<img
src="{{ $resource.Permalink }}"
width="{{ $resource.Width }}"
height="{{ $resource.Height }}"
data-thumbnail
style="background-image: url('data:{{ $thumbnail.MediaType }};base64,{{ $thumbnail.Content | base64Encode }}')"
>
{{- with $title -}}
2022-08-07 17:40:13 +08:00
<figcaption><h4>{{ . }}</h4></figcaption>
2022-08-07 17:23:16 +08:00
{{- end -}}
</figure>