hugo_frigg/layouts/archives/single.html

51 lines
1.6 KiB
HTML

{{ partial "header.html" . }}
<body>
<main class="wrapper">
{{ partial "navigation.html" . }}
<section class="container archive">
<article>
<header class="post-header">
<h1 class="post-title">
{{ .Title }}
</h1>
{{ $img := newScratch }}
{{ $folder := (print "/content/" .File.Dir "gallery/") }}
{{ $files := readDir $folder }}
{{ $img.Set "max" 0 }}
{{ range sort $files "Name" "asc" }}
{{ if not .IsDir }}
{{ if not (in .Name "thumb") }}
{{ $img.Add "list" (slice .Name) }}
{{ $img.Set "max" (add ($img.Get "max") 1) }}
{{ end }}
{{ end }}
{{ end }}
{{ range $index, $val := $img.Get "list" }}
{{ $curr := index (split $val ".") 0 }}
{{ $prec := mod (add (sub $index 1) ($img.Get "max")) ($img.Get "max") }}
{{ $next := mod (add $index 1) ($img.Get "max") }}
<a class="thumb hidden_link" href="#img{{ $index }}">
<picture>
<source srcset="gallery/{{ $curr }}.thumb.avif" type="image/avif"/>
<source srcset="gallery/{{ $curr }}.thumb.webp" type="image/webp"/>
<img src="gallery/{{ $curr }}.thumb.jpg"/>
</picture>
</a>
<!-- lightbox container hidden with CSS -->
<div class="lightbox" id="img{{ $index }}">
<a href="#img{{ $prec }}" class="light-btn hidden_link btn-prev"><<</a>
<a href="#_" class="btn-close hidden_link">X</a>
<img src="gallery/{{ $val }}">
<a href="#img{{ $next }}" class="light-btn hidden_link btn-next">>></a>
</div>
{{ end }}
</header>
<div class="archive-body">
{{ .Content }}
</div>
{{ partial "article-footer.html" . }}
</article>
</section>
</main>
</body>
</html>