From e4e9378f7e020e83c56d4802c16c67adf388d290 Mon Sep 17 00:00:00 2001 From: danix Date: Tue, 14 Mar 2023 17:38:35 +0100 Subject: [PATCH] fixed the figure shortcode to play well with our img shortcode. --- layouts/shortcodes/figure.html | 27 +++++++++++++++++++++++++++ layouts/shortcodes/img.html | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 layouts/shortcodes/figure.html diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html new file mode 100644 index 0000000..86ae6b7 --- /dev/null +++ b/layouts/shortcodes/figure.html @@ -0,0 +1,27 @@ +{{/* + * This version of the figure shortcode needs to be closed and doesn't + * add an image itself, but relies on the img.html shortcode to provide + * a responsive image instead. + */}} + + {{- if .Get "link" -}} + + {{- end -}} + {{- .Inner -}} + {{- if .Get "link" }}{{ end -}} + {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}} +
+ {{ with (.Get "title") -}} +

{{ . }}

+ {{- end -}} + {{- if or (.Get "caption") (.Get "attr") -}}

+ {{- .Get "caption" | markdownify -}} + {{- with .Get "attrlink" }} + + {{- end -}} + {{- .Get "attr" | markdownify -}} + {{- if .Get "attrlink" }}{{ end }}

+ {{- end }} +
+ {{- end }} + diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html index 2f0bd67..e93d5aa 100644 --- a/layouts/shortcodes/img.html +++ b/layouts/shortcodes/img.html @@ -27,7 +27,7 @@ $CFPstyle is for use in styling the div's background, as you'll see shortly. */}} -{{- $CFPstyle := printf "%s%s%s" "background: url(data:image/jpeg;base64," $LQIP_b64 "); background-size: cover; background-repeat: no-repeat;" -}} +{{- $CFPstyle := printf "%s%s%s%v%s%v%s" "background: url(data:image/jpeg;base64," $LQIP_b64 "); background-size: cover; background-repeat: no-repeat; width: " $source.Width "; height: " $source.Height ";" -}} {{/* Then, we create a 640-pixel-wide JPG of the image. This will serve as the -- 2.20.1