mirror of https://github.com/jpanther/congo.git
♻️ Refactor figure shortcode to reduce repetition
parent
68e37ab7a5
commit
3bfc6ae439
|
@ -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
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
{{ $caption := .Get "caption" }}
|
||||
{{ $href := .Get "href" }}
|
||||
{{ $class := .Get "class" }}
|
||||
<figure{{ with $class }} class="{{ . }}"{{ end }}>
|
||||
{{ with $href }}<a href="{{ . }}">{{ end }}
|
||||
<img
|
||||
class="mx-auto my-0 rounded-md"
|
||||
alt="{{ $altText }}"
|
||||
{{ if findRE "^https?" $url.Scheme }}
|
||||
<figure>
|
||||
<img class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" />
|
||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
src="{{ $url.String }}"
|
||||
{{ else }}
|
||||
{{ $resource := "" }}
|
||||
{{ if $.Page.Resources.GetMatch ($url.String) }}
|
||||
|
@ -19,10 +21,6 @@
|
|||
{{ $resource = resources.Get ($url.String) }}
|
||||
{{ end }}
|
||||
{{ with $resource }}
|
||||
<figure {{ with $class }}class="{{ . }}"{{ end }}>
|
||||
{{ with $href }}<a href="{{ . }}">{{ end }}
|
||||
<img
|
||||
class="mx-auto my-0 rounded-md"
|
||||
{{ if or (lt .Width 660) (eq .MediaType.SubType "svg") }}
|
||||
src="{{ .RelPermalink }}"
|
||||
{{ else }}
|
||||
|
@ -33,16 +31,12 @@
|
|||
{{ (.Resize "1320x").RelPermalink }} 2x"
|
||||
src="{{ (.Resize "660x").RelPermalink }}"
|
||||
{{ end }}
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{ if $href }}</a>{{ end }}
|
||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ else }}
|
||||
<figure>
|
||||
<img class="mx-auto my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" />
|
||||
src="{{ $url.String }}"
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
/>
|
||||
{{ with $href }}</a>{{ end }}
|
||||
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in New Issue