« get me outta code hell

content: generateAlbumSidebarGroupBox: fix bug in mixed date/no-date groups - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-14 12:42:45 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-14 12:42:45 -0300
commit3657d69aeb50092f210943a3a00ff147ec48c633 (patch)
treecaff21d8aa3ec21ba8cce442f9945604f955b9a8 /src
parent890852995527df7f6362908b039d28a72bb60f97 (diff)
content: generateAlbumSidebarGroupBox: fix bug in mixed date/no-date groups
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateAlbumSidebarGroupBox.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/content/dependencies/generateAlbumSidebarGroupBox.js b/src/content/dependencies/generateAlbumSidebarGroupBox.js
index 94536c3b..e124acd9 100644
--- a/src/content/dependencies/generateAlbumSidebarGroupBox.js
+++ b/src/content/dependencies/generateAlbumSidebarGroupBox.js
@@ -20,24 +20,26 @@ export default {
       group.urls.map(url =>
         relation('linkExternal', url));
 
-    const albums = group.albums.filter(album => album.date);
-    const index = albums.indexOf(album);
-    const previousAlbum = (index > 0) && albums[index - 1];
-    const nextAlbum = (index < albums.length - 1) && albums[index + 1];
-
     if (group.descriptionShort) {
       relations.description =
         relation('transformContent', group.descriptionShort);
     }
 
-    if (previousAlbum) {
-      relations.previousAlbumLink =
-        relation('linkAlbum', previousAlbum);
-    }
-
-    if (nextAlbum) {
-      relations.nextAlbumLink =
-        relation('linkAlbum', nextAlbum);
+    if (album.date) {
+      const albums = group.albums.filter(album => album.date);
+      const index = albums.indexOf(album);
+      const previousAlbum = (index > 0) && albums[index - 1];
+      const nextAlbum = (index < albums.length - 1) && albums[index + 1];
+
+      if (previousAlbum) {
+        relations.previousAlbumLink =
+          relation('linkAlbum', previousAlbum);
+      }
+
+      if (nextAlbum) {
+        relations.nextAlbumLink =
+          relation('linkAlbum', nextAlbum);
+      }
     }
 
     return relations;