From d9b059dc01024fb1d096d2b8cd1c041315c6a7ed Mon Sep 17 00:00:00 2001 From: gribse Date: Thu, 17 Apr 2025 21:43:28 +0200 Subject: [PATCH] Add custom figure and gallery shortcodes from liwenyip --- layouts/shortcodes/figure.html | 29 +++++++++++++++++++++++ layouts/shortcodes/gallery.html | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 layouts/shortcodes/figure.html create mode 100644 layouts/shortcodes/gallery.html diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html new file mode 100644 index 0000000..3676c68 --- /dev/null +++ b/layouts/shortcodes/figure.html @@ -0,0 +1,29 @@ + + +{{- if not ($.Page.Scratch.Get "figurecount") }}{{ end }} +{{- $.Page.Scratch.Add "figurecount" 1 -}} + +{{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }} +
+
+
+ +
+ {{ with .Get "link" | default (.Get "src") }}{{ end }} + {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} +
+ {{- with .Get "title" }}

{{.}}

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

+ {{- .Get "caption" -}} + {{- with .Get "attrlink"}}{{ .Get "attr" }}{{ else }}{{ .Get "attr"}}{{ end -}} +

+ {{- end }} +
+ {{- end }} +
+
diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html new file mode 100644 index 0000000..6c644b9 --- /dev/null +++ b/layouts/shortcodes/gallery.html @@ -0,0 +1,41 @@ + + +{{- if not ($.Page.Scratch.Get "figurecount") }}{{ end }} +{{- $.Page.Scratch.Add "figurecount" 1 }} +{{ $baseURL := .Site.BaseURL }} +