add overlay section

add use json to store images data
This commit is contained in:
Spedon
2023-03-11 14:37:15 +08:00
parent f1923b3d80
commit a36abb412a

View File

@@ -10,21 +10,27 @@
<header> <header>
{{- partial "header.html" . -}} {{- partial "header.html" . -}}
</header> </header>
<div class="overlay">
<section class="prev_section"></section>
<section class="close_section"></section>
<section class="next_section"></section>
<div class="overlay_cursor"></div>
</div>
<div id="main"> <div id="main">
{{ $sourcePath := "images" }} {{ $sourcePath := "images" }}
{{ $gallery := site.GetPage $sourcePath }} {{ $gallery := site.GetPage $sourcePath }}
{{ $images := $gallery.Resources.ByType "image" }} {{ with $gallery.Resources.ByType "image" }}
{{ $index := len $images }} {{ $index := len . }}
<script type="text/javascript"> {{ $.Scratch.Add "img" slice }}
document.body.setAttribute('featuredPicNum', {{ $index }}) {{ range . }}
</script> {{ $index = sub $index 1}}
{{ range $images }} {{ $.Scratch.Add "img" (dict "link" .RelPermalink "height" .Height "width" .Width) }}
{{ $index = sub $index 1}} <div class="image_container" data-index="{{ $index }}" data-status="inactive">
<div class="image inactive" data-index="{{ $index }}"> <img src="{{ .RelPermalink }}" height="{{ .Height }}" width="{{ .Width }}"/>
<img src="{{ .RelPermalink }}" height="{{ .Height }}" width="{{ .Width }}"/> </div>
</div> {{ end }}
<script id="images_array" type="application/json">{{ $.Scratch.Get "img" | jsonify | safeJS }}</script>
{{ end }} {{ end }}
</div> </div>
<footer> <footer>
{{ partial "footer.html" . }} {{ partial "footer.html" . }}