From 9b13c1eb3766aeec4be518a755b209d6e0cdfd42 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 14 Feb 2024 12:35:06 -0400 Subject: content: filter out & cleanly handle dateless things in chronology --- src/content/dependencies/generateAlbumInfoPage.js | 13 +++++++----- src/content/dependencies/generateTrackInfoPage.js | 24 +++++++++++++++-------- 2 files changed, 24 insertions(+), 13 deletions(-) (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js index 26aa4376..7fbe4e23 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 = diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index ef38ba6b..9cce744b 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -64,11 +64,16 @@ export default { linkArtist: artist => relation('linkArtist', artist), linkThing: track => relation('linkTrack', track), - getThings: artist => - sortAlbumsTracksChronologically([ + getThings(artist) { + const getDate = thing => thing.date; + + const things = [ ...artist.tracksAsArtist, ...artist.tracksAsContributor, - ]), + ].filter(getDate); + + return sortAlbumsTracksChronologically(things, {getDate}); + }, }); relations.coverArtistChronologyContributions = @@ -82,13 +87,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.albumLink = -- cgit 1.3.0-6-gf8a5