From 7ffa6c068cbaba5acba05539e1befcd9432fb161 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Wed, 27 Oct 2021 09:48:13 -0500 Subject: [PATCH] Improve figures - Add option to disable border and caption --- assets/css/bobastyle.css | 2 +- layouts/_default/single.html | 2 +- layouts/_default/summary.html | 2 +- layouts/partials/figure.html | 12 ++++++++++++ layouts/shortcodes/figure.html | 15 ++++++++++++++- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/assets/css/bobastyle.css b/assets/css/bobastyle.css index 31b2018..9aa7a8c 100644 --- a/assets/css/bobastyle.css +++ b/assets/css/bobastyle.css @@ -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; } diff --git a/layouts/_default/single.html b/layouts/_default/single.html index dbdae26..55c4658 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -19,7 +19,7 @@ {{ with .Resources.GetMatch "feature" }}
- {{ partial "figure.html" . }} + {{ partial "figure.html" (dict "src" . "border" true) }}
{{ end }} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index 78af37d..3027e3c 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -13,7 +13,7 @@ {{ with .Resources.GetMatch "feature" }}
- {{ partial "figure.html" . }} + {{ partial "figure.html" (dict "src" . "border" true) }}
{{ end }} diff --git a/layouts/partials/figure.html b/layouts/partials/figure.html index 1d0804f..8e04af5 100644 --- a/layouts/partials/figure.html +++ b/layouts/partials/figure.html @@ -1,4 +1,12 @@ +{{ $hidecaption := index . "hidecaption" }} + +{{ if index . "border" }} +
+{{ else }}
+{{ end }} + {{ with index . "src" }} + {{ $media := . | resources.Fingerprint "sha512" }} {{ if eq .MediaType.MainType "image" }} {{ $media.Title }} @@ -9,9 +17,13 @@ {{ end }} + {{ if not $hidecaption }} {{ with $media.Title }}
{{ . | markdownify }}
{{ end }} + {{ end }} + + {{ end }}
diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index d364561..5eb286d 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -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 }} + +

+ {{ partial "figure.html" (dict "src" $resource "border" $border "hidecaption" $hidecaption) }} +