Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zwbetz-gh/cayman-hugo-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzwbetz <zwbetz@gmail.com>2019-04-02 21:27:00 +0300
committerzwbetz <zwbetz@gmail.com>2019-04-02 21:27:00 +0300
commit478ae7774a189df479e983613019b248705b038b (patch)
treeb29ea10f58d1f9fe53d45c4b193c7ae851bd8220 /layouts
parent51469b0fd3ef7904dcdae0bda768ae98341d1ff4 (diff)
Add figure shortcode & a post to show it off
Diffstat (limited to 'layouts')
-rw-r--r--layouts/shortcodes/figure.html30
1 files changed, 30 insertions, 0 deletions
diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html
new file mode 100644
index 0000000..b05f8d1
--- /dev/null
+++ b/layouts/shortcodes/figure.html
@@ -0,0 +1,30 @@
+{{ $img := .Get "img" }}
+{{ $caption := .Get "caption" }}
+{{ $command := .Get "command" }}
+{{ $options := .Get "options" }}
+
+{{ $original := .Page.Resources.GetMatch (printf "*%s*" $img) }}
+{{ $new := "" }}
+
+{{ if eq $command "Fit" }}
+ {{ $new = $original.Fit $options }}
+{{ else if eq $command "Fill" }}
+ {{ $new = $original.Fill $options }}
+{{ else if eq $command "Resize" }}
+ {{ $new = $original.Resize $options }}
+{{ else if eq $command "Original" }}
+ {{ $new = $original }}
+{{ else }}
+ {{ errorf "Invalid image processing command: Must be one of Fit, Fill, Resize, Original." }}
+{{ end }}
+
+{{ $captionId := printf "caption-%s" ($caption | md5) }}
+
+<figure role="group" aria-describedby="{{ $captionId }}">
+ <a href="{{ $original.Permalink }}" class="">
+ <img src="{{ $new.Permalink }}">
+ </a>
+ <figcaption id="{{ $captionId }}">
+ {{ $caption | markdownify }}
+ </figcaption>
+</figure>