From 8be0fae4818ad19fce9fd7aa067d66f724fb22fa Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Sat, 9 Apr 2022 08:54:58 -0700 Subject: [PATCH] Templates: drop unused class, support img scaling - The .footnote-ref class was unused, drop it. - Support supplying a scale-factor property to the picture shortcode, to upscale small images. --- layouts/partials/processed-content.html | 4 ++-- layouts/shortcodes/picture.html | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/layouts/partials/processed-content.html b/layouts/partials/processed-content.html index 9510d09..f88555b 100644 --- a/layouts/partials/processed-content.html +++ b/layouts/partials/processed-content.html @@ -7,8 +7,8 @@ {{ $referencesWithHeading := printf `

%s

` ($heading) -}} - -{{ $endnote := `(role="doc-endnote")` }} + +{{ $endnote := `(role="doc-endnote"|class="footnote-ref")` }} {{ $noEndnote := printf "" }} diff --git a/layouts/shortcodes/picture.html b/layouts/shortcodes/picture.html index 0fdaec4..2ae7e66 100644 --- a/layouts/shortcodes/picture.html +++ b/layouts/shortcodes/picture.html @@ -8,6 +8,13 @@ {{ $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")) -}} + +{{- $img_width := $light_png.Width -}} +{{- $img_height := $light_png.Height -}} +{{- with (.Get "sf") -}} + {{- $img_width = (mul $img_width . ) -}} + {{- $img_height = (mul $img_height . ) -}} +{{- end -}} {{ with $dark_svg -}} {{ $dark_svg_src := . | resources.Fingerprint "md5" -}} @@ -73,7 +80,7 @@ srcset="{{ $light_png_src.RelPermalink }}" type="image/png"> {{ .Get "alt" }} {{- /* Strip trailing newline: https://github.com/gohugoio/hugo/issues/1753 */ -}}