commit d0e26efc98e61bdd66a28aaa5da2023adb4878d4
parent 5bed374fb1e47ea2eefc6b3468164dec9bac3b28
Author: Leah (ctucx) <leah@ctu.cx>
Date: Sun, 14 Mar 2021 13:35:49 +0100
parent 5bed374fb1e47ea2eefc6b3468164dec9bac3b28
Author: Leah (ctucx) <leah@ctu.cx>
Date: Sun, 14 Mar 2021 13:35:49 +0100
gallery.nim, album.html: only show dividier if there are photos and albums
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/assets/album.html b/src/assets/album.html @@ -91,10 +91,12 @@ <main class="zoomIn"> {{#hasSubalbums}} + {{#showDivider}} <div class="divider"> <h1>Albums</h1> </div> - + {{/showDivider}} + <div id="albums" class="flex"> {{#subalbums}} <a href="{{name}}/" class="album"> @@ -109,9 +111,11 @@ {{/subalbums}} </div> + {{#showDivider}} <div class="divider"> <h1>Photos</h1> </div> + {{/showDivider}} {{/hasSubalbums}} <div id="photos" class="flex"> @@ -133,6 +137,5 @@ {{#enableJS}} <script src="/albums.js"></script> {{/enableJS}} - </body> </html>
diff --git a/src/gallery.nim b/src/gallery.nim @@ -55,6 +55,8 @@ const var config* {.threadvar.}: Config + + ### # # Utils @@ -214,6 +216,7 @@ proc generateWebsite(targetDir: string, album: Album) = "numPictures": album.pictures.len, "isSubalbum": true, "hasSubalbums": false, + "showDivider": false, "subalbums": [], "pictures": [] }, %config) @@ -223,9 +226,10 @@ proc generateWebsite(targetDir: string, album: Album) = mediumThumbnails = newSeq[string]() bigThumbnails = newSeq[string]() - if album.path == "": templateContext["isSubalbum"] = %false - if album.subalbums.len != 0: templateContext["hasSubalbums"] = %true - if not album.desc.isNone: templateContext["description"] = %album.desc.get + if album.path == "": templateContext["isSubalbum"] = %false + if album.subalbums.len != 0: templateContext["hasSubalbums"] = %true + if not album.desc.isNone: templateContext["description"] = %album.desc.get + if album.subalbums.len > 0 and album.pictures.len > 0: templateContext["showDivider"] = %true for subalbum in album.subalbums: generateWebsite(joinPath(targetDir, subalbum.name), subalbum)