From 7856f940b40b4459834a7abfb7a9588ce157f008 Mon Sep 17 00:00:00 2001 From: Dave Kerr Date: Fri, 30 Apr 2021 20:56:11 +0800 Subject: feat(figure-zoom): adds the 'figure-zoom' shortcode --- exampleSite/content/posts/figure-zoom-sample.md | 25 ++++++++++++++++++++ exampleSite/static/images/kitten.jpg | Bin 0 -> 17319 bytes layouts/shortcodes/figure-zoom.html | 29 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 exampleSite/content/posts/figure-zoom-sample.md create mode 100644 exampleSite/static/images/kitten.jpg create mode 100644 layouts/shortcodes/figure-zoom.html diff --git a/exampleSite/content/posts/figure-zoom-sample.md b/exampleSite/content/posts/figure-zoom-sample.md new file mode 100644 index 0000000..2aaa684 --- /dev/null +++ b/exampleSite/content/posts/figure-zoom-sample.md @@ -0,0 +1,25 @@ +--- +author: "Dave Kerr" +date: 2021-04-30 +linktitle: Figure Zoom Sample +title: Figure Zoom Sample +weight: 10 +--- + +The `figure-zoom` shortcode is a version of the [standard `figure` shortcode](https://gohugo.io/content-management/shortcodes/#figure) which also incorporates [Zoom.js](https://github.com/fat/zoom.js/). + +Here is how the markdown for the shortcode is used: + +``` +{{}} +``` + +It will be shown like this - click on the image to zoom in: + +{{< figure-zoom src="/images/kitten.jpg" + title="It's a Kitten!" + caption="This is a kitten, what else needs to be said?" +>}} diff --git a/exampleSite/static/images/kitten.jpg b/exampleSite/static/images/kitten.jpg new file mode 100644 index 0000000..8ddafeb Binary files /dev/null and b/exampleSite/static/images/kitten.jpg differ diff --git a/layouts/shortcodes/figure-zoom.html b/layouts/shortcodes/figure-zoom.html new file mode 100644 index 0000000..97819dd --- /dev/null +++ b/layouts/shortcodes/figure-zoom.html @@ -0,0 +1,29 @@ + + {{- if .Get "link" -}} + + {{- end -}} + {{ with .Get + {{- if .Get "link" }}{{ end -}} + {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}} +
+ {{ with (.Get "title") -}} +

{{ . }}

+ {{- end -}} + {{- if or (.Get "caption") (.Get "attr") -}}

+ {{- .Get "caption" | markdownify -}} + {{- with .Get "attrlink" }} + + {{- end -}} + {{- .Get "attr" | markdownify -}} + {{- if .Get "attrlink" }}{{ end }}

+ {{- end }} +
+ {{- end }} + -- cgit v1.2.3