« get me outta code hell

content: filter out & cleanly handle dateless things in chronology - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateAlbumInfoPage.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-02-14 12:35:06 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-14 13:26:47 -0400
commit9b13c1eb3766aeec4be518a755b209d6e0cdfd42 (patch)
tree166acab41bc1ca7a385170731dcdfeaa83ecafbd /src/content/dependencies/generateAlbumInfoPage.js
parent7aa6747fd8b29e2690ff3522fac731081b2b8946 (diff)
content: filter out & cleanly handle dateless things in chronology
Diffstat (limited to 'src/content/dependencies/generateAlbumInfoPage.js')
-rw-r--r--src/content/dependencies/generateAlbumInfoPage.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js
index 26aa437..7fbe4e2 100644
--- a/src/content/dependencies/generateAlbumInfoPage.js
+++ b/src/content/dependencies/generateAlbumInfoPage.js
@@ -54,13 +54,16 @@ export default {
             ? relation('linkTrack', trackOrAlbum)
             : relation('linkAlbum', trackOrAlbum)),
 
-        getThings: artist =>
-          sortAlbumsTracksChronologically([
+        getThings(artist) {
+          const getDate = thing => thing.coverArtDate ?? thing.date;
+
+          const things = [
             ...artist.albumsAsCoverArtist,
             ...artist.tracksAsCoverArtist,
-          ], {
-            getDate: thing => thing.coverArtDate ?? thing.date,
-          }),
+          ].filter(getDate);
+
+          return sortAlbumsTracksChronologically(things, {getDate});
+        },
       });
 
     relations.albumNavAccent =