File tree Expand file tree Collapse file tree 2 files changed +53
-1
lines changed
Expand file tree Collapse file tree 2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 1+ {{- $url := .url -}}
2+ {{ $img := .img }}
3+ {{ $absoluteURL := .absoluteURL }}
4+ {{ $dims := .dims }}
5+ {{- $ratio := .ratio -}}
6+ {{ $hook := .hook }}
7+ {{ $transform := .transform }}
8+ {{ $format := .format }}
9+ {{ $includeWidth := .includeWidth | default true }}
10+ {{ $anchor := .anchor | default "" }}
11+
12+ {{ $host := (urls.Parse $url).Hostname }}
13+ {{ $dir := (urls.Parse $url).Path }}
14+ {{ $file := index ((split $dir "/") | collections.Reverse) 0 }}
15+ {{ $dir = strings.TrimSuffix $file $dir }}
16+
17+ {{ $adapter := (printf "assets/adapters/%s.html" $hook) }}
18+ {{ if not (fileExists (path.Join "/layouts/partials" $adapter)) }}
19+ {{ warnf "Cannot find adapter: %s" (path.Join "/layouts/partials" $adapter) }}
20+ {{ $hook = "hugo" }}
21+ {{ $adapter = "assets/adapters/hugo.html" }}
22+ {{ end }}
23+
24+ {{ $imgset := slice }}
25+ {{- range $index, $dim := $dims -}}
26+ {{ $width := (int (index (split $dim "x") 0)) }}
27+ {{ $height := "" }}
28+ {{ if $height }}
29+ {{ $height = (int (index (split $dim "x") 1)) }}
30+ {{ end }}
31+
32+ {{- $element := partial $adapter (dict
33+ "host" $host
34+ "dir" $dir
35+ "file" $file
36+ "img" $img
37+ "absoluteURL" $absoluteURL
38+ "transform" $transform
39+ "width" $width
40+ "height" $height
41+ "format" $format
42+ "anchor" $anchor
43+ )}}
44+ {{ if $includeWidth }}
45+ {{ $imgset = $imgset | append (printf "%s %dw" $element $width) }}
46+ {{ else }}
47+ {{ $imgset = $imgset | append $element }}
48+ {{ end }}
49+ {{- end -}}
50+
51+ {{ return (delimit $imgset ", ") }}
Original file line number Diff line number Diff line change 11{{- $ratio := .Get "ratio" | default "auto" -}}
2+ {{- $ratioThumbnail := .Get "ratioThumbnail" | default "auto" -}}
23{{- $loading := .Get "loading" | default "lazy" -}}
34
45<!-- Initialize $images to prevent the undefined variable error -->
5253 {{ $title := $image.title }}
5354 {{ $imageClass := "slideshow-thumbnail-image cursor" }}
5455 < div class ="slideshow-thumbnail-column ">
55- {{ partial "assets/image.html" (dict "url" $imageUrl "ratio " $ratio "page " $.Page "class" $imageClass "loading" $loading "title" $title) }}
56+ {{ partial "assets/image.html" (dict "url" $imageUrl "page " $.Page "ratio " $ratioThumbnail "class" $imageClass "loading" $loading "title" $title) }}
5657 </ div >
5758 {{- end -}}
5859 {{- end -}}
You can’t perform that action at this time.
0 commit comments