From dc87c07b2430e6a6799d4e2222d7dc09de757a58 Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 15 Jan 2023 23:59:21 -0800 Subject: [PATCH] Use img.html directly if no caption --- .../content/blog/gallery-shortcode/index.md | 9 ++++ layouts/shortcodes/paige/gallery.html | 49 +++++++++++++------ 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/exampleSite/content/blog/gallery-shortcode/index.md b/exampleSite/content/blog/gallery-shortcode/index.md index c341c991..c6eaba3b 100644 --- a/exampleSite/content/blog/gallery-shortcode/index.md +++ b/exampleSite/content/blog/gallery-shortcode/index.md @@ -195,6 +195,15 @@ Result: ## Customization +{{< paige/gallery caption="X image" >}} + {{< paige/gallery image="*-1*.jpg" height="10rem" />}} + {{< paige/gallery image="*-1*.jpg" height="10rem" />}} + {{< paige/gallery image="*-1*.jpg" height="10rem" />}} + {{< paige/gallery image="*-1*.jpg" height="10rem" />}} +{{< /paige/gallery >}} + +--- + Code: ```go-text-template diff --git a/layouts/shortcodes/paige/gallery.html b/layouts/shortcodes/paige/gallery.html index f60eed27..2d9a9b1d 100644 --- a/layouts/shortcodes/paige/gallery.html +++ b/layouts/shortcodes/paige/gallery.html @@ -24,22 +24,39 @@ {{ $link = $resource.RelPermalink }} {{ end }} - {{ partial "paige/image-figure.html" (dict - "caption" $caption - "compact" true - "height" $height - "link" $link - "maxheight" $maxheight - "maxwidth" $maxwidth - "method" $method - "options" $options - "page" .Page - "raw" $raw - "resource" $resource - "src" $image - "table" true - "width" $width - ) }} + {{ if $caption }} + {{ partial "paige/image-figure.html" (dict + "caption" $caption + "compact" true + "height" $height + "link" $link + "maxheight" $maxheight + "maxwidth" $maxwidth + "method" $method + "options" $options + "page" .Page + "raw" $raw + "resource" $resource + "src" $image + "table" true + "width" $width + ) }} + {{ else }} + {{ partial "paige/a.html" (dict + "content" (partial "paige/img.html" (dict + "class" "img-fluid" + "height" $height + "maxheight" $maxheight + "maxwidth" $maxwidth + "method" $method + "options" $options + "resource" $resource + "src" $image + "width" $width + )) + "href" $link + ) }} + {{ end }} {{ else }} {{ $inner := chomp .Inner }}