diff options
author | amazingrise <8315221+AmazingRise@users.noreply.github.com> | 2020-07-29 09:58:42 +0300 |
---|---|---|
committer | amazingrise <8315221+AmazingRise@users.noreply.github.com> | 2020-07-29 09:58:42 +0300 |
commit | 27f7bfc1f4d054ab2b4a0089c4d1b426f2975203 (patch) | |
tree | a4d6e81942cfe32d06e36216808acf576648e8a9 | |
parent | c2c31f4e379254722b32161cefb3668b3dba519b (diff) |
Add insertFigure shortcode.
-rw-r--r-- | layouts/shortcodes/insertFigure.html | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/layouts/shortcodes/insertFigure.html b/layouts/shortcodes/insertFigure.html new file mode 100644 index 0000000..e220646 --- /dev/null +++ b/layouts/shortcodes/insertFigure.html @@ -0,0 +1,34 @@ +<!-- + From "cupper-hugo-theme" by zwbetz-gh + https://github.com/zwbetz-gh/cupper-hugo-theme/blob/master/layouts/shortcodes/figureCupper.html + Under MIT License +--> +{{ $img := .Get "img" }} +{{ $caption := .Get "caption" }} +{{ $command := .Get "command" }} +{{ $options := .Get "options" }} +{{ $align := .Get "align" }} + +{{ $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 }} + +<figure align="{{$align}}" role="group" aria-describedby="caption-{{ $caption | md5 }}"> + <a href="{{ $original.Permalink }}" class="img-link"> + <img src="{{ $new.Permalink }}"> + </a> + <figcaption id="caption-{{ $caption | md5 }}"> + {{ $caption | markdownify }} + </figcaption> +</figure>
\ No newline at end of file |