aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/gallery-walk.html
blob: ca95d3fba780cc8c7dafd7af8c3d68dc89c1e909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{{- $data          := slice -}}
{{- $author        := partial "function-authors-data.html" . -}}
{{- $filteredPages := partial "function-filters-content.html" .Site.RegularPages -}}

{{- range (where $filteredPages "Section" $author.user) -}}
  {{- if in .Content "<picture>" -}}
    {{- $data = $data | append (dict
        "alt"         (delimit   (findRE `(?sU)alt=".*"`    .Content 1) "")
        "height"      (delimit   (findRE `(?sU)height=".*"` .Content 1) "")
        "src"         (delimit   (findRE `(?sU)src=".*"`    .Content 1) "")
        "srcset"      (delimit   (findRE `(?sU)srcset=".*"` .Content 1) "")
        "style"       (delimit   (findRE `(?sU)style=".*"`  .Content 1) "")
        "title"       (delimit   (findRE `(?sU)title=".*"`  .Content 1) "")
        "type"        (delimit   (findRE `(?sU)type=".*"`   .Content 1) "")
        "width"       (delimit   (findRE `(?sU)width=".*"`  .Content 1) "")
        "relatedHref" .Permalink
      )
    -}}
  {{- end -}}
  {{- if eq (len $data) 6 -}}
    {{- break -}}
  {{- end -}}
{{- end -}}

{{- if $data -}}
  {{- range $image := $data }}
  <a href="{{ $image.relatedHref }}">
    <picture>
      {{- with $image.srcset -}}
        <source
          {{ $image.srcset | safeHTMLAttr }}
          {{ $image.type   | safeHTMLAttr }}
        />
      {{- end -}}
      <img
       loading="lazy"
        {{ $image.alt    | safeHTMLAttr }}
        {{ $image.title  | safeHTMLAttr }}
        {{ with ne (index (last 1 (split $image.width "=")) 0) `""` }}
        {{ $image.width  | safeHTMLAttr }}
        {{ $image.height | safeHTMLAttr }}
        {{ end }}
        {{ $image.src    | safeHTMLAttr }}
        {{ $image.style  | safeHTMLAttr }}
      />
    </picture>
  </a>
  {{ end }}
  <gallery-overlay></gallery-overlay>
{{- end -}}