diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index 6f828b5..28a9de6 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -5,7 +5,7 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ --> -{{- if not ($.Page.Scratch.Get "figurecount") }}{{ end }} +{{- if not ($.Page.Scratch.Get "figurecount") -}}{{- end -}} {{- $.Page.Scratch.Add "figurecount" 1 -}} @@ -14,52 +14,51 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ -{{ $resize_opts := "600x jpg" }} +{{- $resize_opts := "600x jpg" -}} - -{{ $thumb := "" }} -{{ $href := "" }} -{{ if .Get "resource" }} - {{ $page := $.Page }} - {{ with .Get "page" }} - {{ $page = $.Site.GetPage . }} - {{ end }} +{{- $thumb := "" -}} +{{- $href := "" -}} +{{- if .Get "resource" -}} + {{- $page := $.Page -}} + {{- with .Get "page" -}} + {{- $page = $.Site.GetPage . -}} + {{- end -}} {{- if not $page -}} {{- errorf "Error: Can't find page %s" (.Get "page") -}} {{- end -}} - {{ $resource := (.Get "resource") }} - {{ $original := $page.Resources.GetMatch (printf "*%s*" $resource) }} + {{- $resource := (.Get "resource") -}} + {{- $original := $page.Resources.GetMatch (printf "*%s*" $resource) -}} {{- if eq $original nil -}} {{- errorf "Error: Can't find resource %s on page %s" $resource (.Get "page") -}} {{- end -}} - {{ .Scratch.Set "image" ($original.Resize $resize_opts) }} - {{ $image := .Scratch.Get "image" }} - {{- $thumb = $image.RelPermalink }} - {{- $href = $original.RelPermalink }} -{{ else }} + {{- .Scratch.Set "image" ($original.Resize $resize_opts) -}} + {{- $image := .Scratch.Get "image" -}} + {{- $thumb = $image.RelPermalink -}} + {{- $href = $original.RelPermalink -}} +{{- else -}} - {{- $thumb = .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }} - {{- $href = .Get "link" | default (.Get "src") }} -{{ end }} + {{- $thumb = .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") -}} + {{- $href = .Get "link" | default (.Get "src") -}} +{{- end -}}
{{- .Get "caption" -}} {{- with .Get "attrlink"}}{{ .Get "attr" }}{{ else }}{{ .Get "attr"}}{{ end -}}
- {{- end }} + {{- end -}}