~dricottone/blog

ref: 00610dc1ac33e31da18457097aa5a61e799a254a blog/layouts/shortcodes/gallery.html -rw-r--r-- 802 bytes
00610dc1Dominic Ricottone New post 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<div class="gallery">
  {{ $gallery_src := print (.Get "src") }}
  {{ $local_dir := print "static/" $gallery_src }}
  {{ range (readDir $local_dir) }}
    {{ $web_src := print $gallery_src "/" .Name }}
    {{ if strings.HasSuffix .Name "webm" }}
      <video controls loop width="200">
        <source src="{{ $web_src }}" type="video/webm">
        <p>Video <a href="{{ $web_src }}">here</a></p>
      </video>
    {{ else if (strings.HasSuffix .Name "mp4") }}
      <video controls loop width="200">
        <source src="{{ $web_src }}" type="video/mp4">
        <p>Video <a href="{{ $web_src }}">here</a></p>
      </video>
    {{ else }}
      <a href="{{ $web_src }}" data-lightbox="{{ $gallery_src }}">
        <img src="{{ $web_src }}" height="100" />
      </a>
    {{ end}}
  {{ end }}
</div>