« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
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;