aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/gallery-walk.html
blob: 6c2206f41af2f24bbd3490496f4272c67b475b63 (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
51
52
53
54
55
{{- $data := slice -}}
{{- $author := partial "function-authors-data.html" . -}}

{{- $mimes := slice
  "image/apng"
  "image/avif"
  "image/gif"
  "image/jpeg"
  "image/png"
  "image/svg+xml"
  "image/webp"
-}}

{{- range (where .Site.RegularPages "Params.Author" $author.user) -}}
  {{- if in .Content "<figure>" -}}
    {{- $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>
      <source
        {{ $image.srcset | safeHTMLAttr }}
        {{ $image.type   | safeHTMLAttr }}
      />
      <img
       loading="lazy"
        {{ $image.alt    | safeHTMLAttr }}
        {{ $image.title  | safeHTMLAttr }}
        {{ $image.width  | safeHTMLAttr }}
        {{ $image.height | safeHTMLAttr }}
        {{ $image.src    | safeHTMLAttr }}
        {{ $image.style  | safeHTMLAttr }}
      />
    </picture>
  </a>
  {{ end }}
  <gallery-overlay></gallery-overlay>
{{- end -}}