From 54d74316d3683d5f5827bda5b1ea7abf50b60a4b Mon Sep 17 00:00:00 2001
From: James Panther <4462786+jpanther@users.noreply.github.com>
Date: Thu, 3 Feb 2022 11:37:09 +1100
Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Allow=20`figure`=20to=20revert?=
=?UTF-8?q?=20to=20default=20behaviour?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
exampleSite/content/docs/shortcodes/index.md | 9 ++--
layouts/shortcodes/figure.html | 48 +++++++++++---------
2 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/exampleSite/content/docs/shortcodes/index.md b/exampleSite/content/docs/shortcodes/index.md
index b06c9dae..2df0149c 100644
--- a/exampleSite/content/docs/shortcodes/index.md
+++ b/exampleSite/content/docs/shortcodes/index.md
@@ -101,16 +101,17 @@ Congo includes a `figure` shortcode for adding images to content. The shortcode
Images included using `figure` will be optimised using Hugo Pipes and scaled in order to provide images appropriate to different device resolutions.
-The `figure` shortcode accepts five parameters:
+The `figure` shortcode accepts six parameters:
|Parameter|Description|
|---|---|
|`src`|**Required.** The filename of the image. This image must be a [page resource](https://gohugo.io/content-management/page-resources/) bundled with the page.|
|`alt`|[Alternative text description](https://moz.com/learn/seo/alt-text) for the image.|
-|`caption`|Markdown for the image caption which will be displayed below the image.|
-|`class`|Additional CSS classes to add to the image.|
- `href`|URL that the image should be linked to.|
+|`caption`|Markdown for the image caption, which will be displayed below the image.|
+|`class`|Additional CSS classes to apply to the image.|
+|`href`|URL that the image should be linked to.|
+|`default`|Special parameter to revert to default Hugo `figure` behaviour. Simply provide `default=true` and then use normal [Hugo shortcode syntax](https://gohugo.io/content-management/shortcodes/#figure).|
Congo also supports automatic conversion of images included using standard Markdown syntax. Simply use the following format and the theme will handle the rest:
diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html
index 963ec3e4..4bca0c15 100644
--- a/layouts/shortcodes/figure.html
+++ b/layouts/shortcodes/figure.html
@@ -1,23 +1,27 @@
-{{ $altText := .Get "alt" }}
-{{ $caption := .Get "caption" }}
-{{ $href := .Get "href" }}
-{{ $class := .Get "class" }}
-{{ with $.Page.Resources.GetMatch (.Get "src") }}
-
+{{ if .Get "default" }}
+ {{ template "_internal/shortcodes/figure.html" . }}
{{ else }}
- {{ errorf `[CONGO] Shortcode "figure" error in "%s": Resource "%s" not found. Check the path is correct or remove the shortcode.` .Page.Path (.Get "src") }}
-{{ end }}
+ {{ $altText := .Get "alt" }}
+ {{ $caption := .Get "caption" }}
+ {{ $href := .Get "href" }}
+ {{ $class := .Get "class" }}
+ {{ with $.Page.Resources.GetMatch (.Get "src") }}
+
+ {{ else }}
+ {{ errorf `[CONGO] Shortcode "figure" error in "%s": Resource "%s" not found. Check the path is correct or remove the shortcode.` .Page.Path (.Get "src") }}
+ {{ end }}
+{{ end }}
\ No newline at end of file