From: danix Date: Tue, 14 Mar 2023 16:38:35 +0000 (+0100) Subject: fixed the figure shortcode to play well with our img shortcode. X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=e4e9378f7e020e83c56d4802c16c67adf388d290;p=theme-danix.xyz.git fixed the figure shortcode to play well with our img shortcode. --- 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