From 3bfc6ae4395b67fa661f832ba25244dd1fc94765 Mon Sep 17 00:00:00 2001 From: James Panther <4462786+jpanther@users.noreply.github.com> Date: Sat, 14 Jan 2023 11:24:41 +1100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20figure=20shortc?= =?UTF-8?q?ode=20to=20reduce=20repetition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + layouts/shortcodes/figure.html | 72 ++++++++++++++++------------------ 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 118c934c..51501a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Error when attempting to resize SVG assets in page bundles ([#427](https://github.com/jpanther/congo/pull/427)) - Appearance switcher missing `aria-label` ([#438](https://github.com/jpanther/congo/pull/438)) - Article links missing `alt` text and `aria-label` ([#439](https://github.com/jpanther/congo/pull/439)) +- Figure shortcode would not apply `class` or `href` attribtues in some cases ## [2.4.2] - 2022-11-22 diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index bcd105f8..54cff269 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -6,43 +6,37 @@ {{ $caption := .Get "caption" }} {{ $href := .Get "href" }} {{ $class := .Get "class" }} - {{ if findRE "^https?" $url.Scheme }} -
- {{ $altText }} - {{ with $caption }}
{{ . | markdownify }}
{{ end }} -
- {{ else }} - {{ $resource := "" }} - {{ if $.Page.Resources.GetMatch ($url.String) }} - {{ $resource = $.Page.Resources.GetMatch ($url.String) }} - {{ else if resources.GetMatch ($url.String) }} - {{ $resource = resources.Get ($url.String) }} - {{ end }} - {{ with $resource }} -
- {{ with $href }}{{ end }} - {{ $altText }} - {{ if $href }}{{ end }} - {{ with $caption }}
{{ . | markdownify }}
{{ end }} -
- {{ else }} -
- {{ $altText }} - {{ with $caption }}
{{ . | markdownify }}
{{ end }} -
- {{ end }} - {{ end }} + + {{ with $href }}{{ end }} + {{ $altText }} + {{ with $href }}{{ end }} + {{ with $caption }}
{{ . | markdownify }}
{{ end }} + {{ end }}