Use a single figure shortcode that does either image or video

This commit is contained in:
2021-10-19 14:19:23 -05:00
parent 96067c95c0
commit b599ddeadd
7 changed files with 25 additions and 60 deletions

View File

@ -1,22 +0,0 @@
<figure>
{{ $img := $.Page.Resources.GetMatch (.Get "src") | resources.Fingerprint "sha512" }}
{{ if .Get "href" }}<a href="{{ .Get "href" }}">{{ end }}
<img src="{{ $img.Permalink }}"
{{ with $img.Title }}
alt="{{ . }}"
{{ end }}
{{ with .Get "width" }}width="{{ . }}"{{ end }}
{{ with .Get "height" }}height="{{ . }}"{{ end }}
/>
{{ if .Get "href" }}</a>{{ end }}
{{ with $img.Title }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
</figure>

View File

@ -0,0 +1,2 @@
{{ $resource := $.Page.Resources.GetMatch (.Get "src") }}
{{ partial "figure.html" $resource }}

View File

@ -1,18 +0,0 @@
<figure>
{{ $vid := $.Page.Resources.GetMatch (.Get "src") | resources.Fingerprint "sha512" }}
{{ if .Get "href" }}<a href="{{ .Get "href" }}">{{ end }}
<video controls>
<source src="{{ $vid.Permalink }}" alt="{{ $vid.Title }}">
{{ i18n "browser_no_video_support" }}
</video>
{{ if .Get "href" }}</a>{{ end }}
{{ with $vid.Title }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
</figure>