mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-24 05:02:10 +00:00
aad8b11a70
- New shortcode for quotation. Not using this yet. - Make picture shortcode round image dimensions to integer values. - Make quotecaption support code snippets borrowed from other places. Not using this yet.
94 lines
3.3 KiB
HTML
94 lines
3.3 KiB
HTML
{{ $light_svg := resources.GetMatch (printf "/p/%s.svg" (.Get "name")) -}}
|
|
{{ $light_png := resources.GetMatch (printf "/p/%s.png" (.Get "name")) -}}
|
|
{{ $light_webp := resources.GetMatch (printf "/p/%s.webp" (.Get "name")) -}}
|
|
{{ $light_avif := resources.GetMatch (printf "/p/%s.avif" (.Get "name")) -}}
|
|
{{ $light_jxl := resources.GetMatch (printf "/p/%s.jxl" (.Get "name")) -}}
|
|
{{ $dark_svg := resources.GetMatch (printf "/p/%s_dark.svg" (.Get "name")) -}}
|
|
{{ $dark_png := resources.GetMatch (printf "/p/%s_dark.png" (.Get "name")) -}}
|
|
{{ $dark_webp := resources.GetMatch (printf "/p/%s_dark.webp" (.Get "name")) -}}
|
|
{{ $dark_avif := resources.GetMatch (printf "/p/%s_dark.avif" (.Get "name")) -}}
|
|
{{ $dark_jxl := resources.GetMatch (printf "/p/%s_dark.jxl" (.Get "name")) -}}
|
|
|
|
{{- $isPix := false -}}
|
|
{{- $img_width := $light_png.Width -}}
|
|
{{- $img_height := $light_png.Height -}}
|
|
{{- with (.Get "sf") -}}
|
|
{{- $img_width = (mul $img_width . | math.Round) -}}
|
|
{{- $img_height = (mul $img_height . | math.Round ) -}}
|
|
{{- if eq . 2 -}}
|
|
{{- $isPix = true -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
<picture{{ if $isPix }} class="pix"{{ end }}>
|
|
{{ with $dark_svg -}}
|
|
{{ $dark_svg_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $dark_svg_src.RelPermalink }}"
|
|
type="image/svg+xml"
|
|
media="screen and (prefers-color-scheme: dark)">
|
|
{{ end -}}
|
|
{{ with $dark_jxl -}}
|
|
{{ $dark_jxl_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $dark_jxl_src.RelPermalink }}"
|
|
type="image/jxl"
|
|
media="screen and (prefers-color-scheme: dark)">
|
|
{{ end -}}
|
|
{{ with $dark_avif -}}
|
|
{{ $dark_avif_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $dark_avif_src.RelPermalink }}"
|
|
type="image/avif"
|
|
media="screen and (prefers-color-scheme: dark)">
|
|
{{ end -}}
|
|
{{ with $dark_webp -}}
|
|
{{ $dark_webp_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $dark_webp_src.RelPermalink }}"
|
|
type="image/webp"
|
|
media="screen and (prefers-color-scheme: dark)">
|
|
{{ end -}}
|
|
{{ with $dark_png -}}
|
|
{{ $dark_png_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $dark_png_src.RelPermalink }}"
|
|
type="image/png"
|
|
media="screen and (prefers-color-scheme: dark)">
|
|
{{ end -}}
|
|
{{ with $light_svg -}}
|
|
{{ $light_svg_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $light_svg_src.RelPermalink }}"
|
|
type="image/svg+xml">
|
|
{{ end -}}
|
|
{{ with $light_jxl -}}
|
|
{{ $light_jxl_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $light_jxl_src.RelPermalink }}"
|
|
type="image/jxl">
|
|
{{ end -}}
|
|
{{ with $light_avif -}}
|
|
{{ $light_avif_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $light_avif_src.RelPermalink }}"
|
|
type="image/avif">
|
|
{{ end -}}
|
|
{{ with $light_webp -}}
|
|
{{ $light_webp_src := . | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $light_webp_src.RelPermalink }}"
|
|
type="image/webp">
|
|
{{ end -}}
|
|
{{ $light_png_src := $light_png | resources.Fingerprint "md5" -}}
|
|
<source
|
|
srcset="{{ $light_png_src.RelPermalink }}"
|
|
type="image/png">
|
|
<img
|
|
width="{{ $img_width }}" height="{{ $img_height }}"
|
|
src="{{ $light_png.RelPermalink }}" alt='{{ .Get "alt" }}'
|
|
{{ with .Parent -}}
|
|
{{- with .Get "id" -}}
|
|
aria-describedby="transcript-{{ . }}"
|
|
{{ end }}{{ end -}}
|
|
decoding="async">
|
|
</picture>{{- /* Strip trailing newline: https://github.com/gohugoio/hugo/issues/1753 */ -}}
|