From 8fa063174efbac5df436cabddc8ab5a353df553b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 4 Jan 2018 10:04:10 +0000 Subject: [PATCH] Add shortcode for embedding resources in content --- layouts/shortcodes/resource.html | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 layouts/shortcodes/resource.html diff --git a/layouts/shortcodes/resource.html b/layouts/shortcodes/resource.html new file mode 100644 index 0000000..4134d48 --- /dev/null +++ b/layouts/shortcodes/resource.html @@ -0,0 +1,28 @@ +{{ $original := .Page.Resources.GetByPrefix (.Get "src") }} +{{ $options := .Get "options" }} + +{{ .Scratch.Set "image" $original }} + +{{ if $options }} + {{ $command := (default "Resize" (.Get "command")) }} + {{ if eq $command "Fit"}} + {{ .Scratch.Set "image" ($original.Fit $options) }} + {{ else if eq $command "Resize"}} + {{ .Scratch.Set "image" ($original.Resize $options) }} + {{ else if eq $command "Fill"}} + {{ .Scratch.Set "image" ($original.Fill $options) }} + {{ end }} +{{ end }} + +{{ $image := .Scratch.Get "image" }} + +{{ if .Inner }} +
+ +
+ {{ .Inner }} +
+
+{{ else }} + +{{ end }}