Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/hivickylai/hugo-theme-sam.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictoria <hello@victoria.dev>2019-04-15 00:04:49 +0300
committerVictoria <hello@victoria.dev>2019-04-15 00:04:49 +0300
commite284c3d1fd46cacc665aab017ef0e650595018d9 (patch)
tree2fb468d2d89a4b39caaeaecfc045735d9c1e04f8 /layouts
parentf11239fda34b38ceb6a34e848324cf81d06b56d8 (diff)
Update gallery template (fix #46, close #35)
- Use Hugo Image Processing and Resources - Move config logic into the gallery Front Matter - Update exampleSite
Diffstat (limited to 'layouts')
-rwxr-xr-xlayouts/gallery/list.html56
1 files changed, 14 insertions, 42 deletions
diff --git a/layouts/gallery/list.html b/layouts/gallery/list.html
index 0057423..6779b20 100755
--- a/layouts/gallery/list.html
+++ b/layouts/gallery/list.html
@@ -3,55 +3,27 @@
{{ .Content }}
</div>
-{{ if .Site.Params.clickablePhotos }}
+{{ if .Params.clickablePhotos }}
<div class="grid">
- {{ $name := .Site.Params.galleryFolder | default "images/"}}
- {{ $path := .File.Dir }}
- {{ $content := "/content/" }}
- {{ $src := (print $path $name) }}
-
- {{ $folder := (print $content $path $name) }}
-
- {{ $files := readDir $folder }}
-
- {{ $previewSubdirectory := .Site.Params.smallImagesSubfolder | default "small/"}}
- {{ $previewImagesEnabled := .Site.Params.smallPreviewImages }}
-
- {{ range shuffle $files }}
-
- {{ if not .IsDir }}
-
+ {{ $images := .Resources.ByType "image" }}
+ {{ range shuffle $images }}
+ {{ $resized := .Resize $.Params.maxWidth }}
<div>
- <a href="{{ $src | absURL }}{{ .Name }}">
- {{ if $previewImagesEnabled}}
- <img src="{{ $src | absURL }}{{ $previewSubdirectory }}{{ .Name }}" alt="{{ .Name }}" />
- {{ else }}
- <img src="{{ $src | absURL }}{{ .Name }}" alt="{{ .Name }}" />
- {{ end }}
- </a>
+ <a href="{{ .RelPermalink }}">
+ <img src="{{ $resized.RelPermalink }}" alt="{{ .Name }}" />
+ </a>
</div>
{{ end }}
-
- {{ end }}
</div>
{{ else }}
<div class="grid">
- {{ $name := .Site.Params.galleryFolder | default "images/"}}
- {{ $path := .File.Dir }}
- {{ $content := "/content/" }}
- {{ $src := (print $path $name) }}
-
- {{ $folder := (print $content $path $name) }}
-
- {{ $files := readDir $folder }}
-
- {{ range shuffle $files }}
- {{ if not .IsDir }}
- <div>
- <img src="{{ $src | absURL }}{{ .Name }}" alt="{{ .Name }}" />
- </div>
- {{ end }}
- {{ end }}
+ {{ $images := .Resources.ByType "image" }}
+ {{ range shuffle $images }}
+ {{ $resized := .Resize $.Params.maxWidth }}
+ <div>
+ <img src="{{ $resized.RelPermalink }}" alt="{{ .Name }}" />
+ </div>
+ {{ end }}
</div>
{{ end }}