From f764775985b446655701ed740c116d598980cb77 Mon Sep 17 00:00:00 2001 From: Derek Severin Date: Sun, 10 Feb 2019 14:08:49 +0700 Subject: Image gallery: fixed directory check & added params in 'single.html' call to partial --- layouts/_default/single.html | 15 ++++----------- layouts/partials/gallery.html | 5 +++-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 566fdf7..b4d3641 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -42,17 +42,10 @@ {{ end }} */}} -{{/* -- "dir" .Params.images_directory - => if not defined: "images" -- "static" .Params.images_static - => if not defined: N/A -- "thumb" .Params.images_thumb_suffix - => if not defined: N/A -... -*/}} -{{ partial "gallery.html" (dict "page" . "dir" "images") }} -{{ partial "load-photoswipe.html" (dict "page" .) }} + {{ $images_directory := .Params.images_directory | default "images" }} + {{ $images_static := .Params.images_static | default "false" }} + {{ partial "gallery.html" (dict "page" . "dir" $images_directory "static" $images_static) }} + {{ partial "load-photoswipe.html" (dict "page" .) }} {{ end }} {{ define "lists" }} diff --git a/layouts/partials/gallery.html b/layouts/partials/gallery.html index 72e11d2..6c7fc4b 100644 --- a/layouts/partials/gallery.html +++ b/layouts/partials/gallery.html @@ -46,8 +46,9 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ {{ $.page.Scratch.Set "dirFiles" (print "/content/" $tmpDir "/") }} {{- end -}} {{- $dir := $.page.Scratch.Get "dirURL" }} - {{ if (fileExists $dir) -}} - {{- $files := readDir ($.page.Scratch.Get "dirFiles" ) }} + {{- $dirFiles := $.page.Scratch.Get "dirFiles" }} + {{ if (fileExists $dirFiles) -}} + {{- $files := readDir ($dirFiles ) }} {{- range $files -}} -- cgit v1.2.3