From 3657d69aeb50092f210943a3a00ff147ec48c633 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 14 Jun 2023 12:42:45 -0300 Subject: content: generateAlbumSidebarGroupBox: fix bug in mixed date/no-date groups --- .../dependencies/generateAlbumSidebarGroupBox.js | 28 ++++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/content') 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; -- cgit 1.3.0-6-gf8a5