Improve figures

- Add option to disable border and caption
This commit is contained in:
BBaoVanC 2021-10-27 09:48:13 -05:00
parent 0cfecdab18
commit 7ffa6c068c
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
5 changed files with 29 additions and 4 deletions

View File

@ -112,7 +112,7 @@ img, video {
max-width: 100%;
}
img:not(.noborder), video:not(.noborder) {
figure.border img, figure.border video {
padding: 5px;
border: 7px solid #1b5b9b;
}

View File

@ -19,7 +19,7 @@
{{ with .Resources.GetMatch "feature" }}
<div class="post-media">
{{ partial "figure.html" . }}
{{ partial "figure.html" (dict "src" . "border" true) }}
</div>
{{ end }}

View File

@ -13,7 +13,7 @@
{{ with .Resources.GetMatch "feature" }}
<div class="post-media">
{{ partial "figure.html" . }}
{{ partial "figure.html" (dict "src" . "border" true) }}
</div>
{{ end }}

View File

@ -1,4 +1,12 @@
{{ $hidecaption := index . "hidecaption" }}
{{ if index . "border" }}
<figure class="border">
{{ else }}
<figure>
{{ end }}
{{ with index . "src" }}
{{ $media := . | resources.Fingerprint "sha512" }}
{{ if eq .MediaType.MainType "image" }}
<img src="{{ $media.Permalink }}" alt="{{ $media.Title }}" />
@ -9,9 +17,13 @@
</video>
{{ end }}
{{ if not $hidecaption }}
{{ with $media.Title }}
<figcaption>
{{ . | markdownify }}
</figcaption>
{{ end }}
{{ end }}
{{ end }}
</figure>

View File

@ -1,2 +1,15 @@
{{ $resource := $.Page.Resources.GetMatch (.Get "src") }}
{{ partial "figure.html" $resource }}
{{ $border := false }}
{{ if .Get "border" }}
{{ $border = true }}
{{ end }}
{{ $hidecaption := false }}
{{ if .Get "hidecaption" }}
{{ $hidecaption = true }}
{{ end }}
<p>
{{ partial "figure.html" (dict "src" $resource "border" $border "hidecaption" $hidecaption) }}
</p>