diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-06 17:55:06 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-08-06 17:55:06 -0300 |
commit | 91136e5a3fedaa7c33d4df00b7e64829b5419157 (patch) | |
tree | 5aaaabd277dea918e2f9ae75c97a3f02aa9f467b | |
parent | b4a808eb2f2b34d4d636b84a1812940ba8728d91 (diff) |
content: generateArtistInfoPageTracksChunkedList: handle "as artist and contributor" gracefully
-rw-r--r-- | src/content/dependencies/generateArtistInfoPageTracksChunkedList.js | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js index d6ae9ae8..6c953f1a 100644 --- a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js +++ b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js @@ -19,8 +19,30 @@ export default { extraDependencies: ['language'], query(artist) { + const tracksAsArtistAndContributor = + artist.tracksAsArtist + .filter(track => artist.tracksAsContributor.includes(track)); + + const tracksAsArtistOnly = + artist.tracksAsArtist + .filter(track => !artist.tracksAsContributor.includes(track)); + + const tracksAsContributorOnly = + artist.tracksAsContributor + .filter(track => !artist.tracksAsArtist.includes(track)); + const entries = [ - ...artist.tracksAsArtist.map(track => ({ + ...tracksAsArtistAndContributor.map(track => ({ + thing: track, + entry: { + track, + album: track.album, + date: track.date, + contribs: [...track.artistContribs, ...track.contributorContribs], + }, + })), + + ...tracksAsArtistOnly.map(track => ({ thing: track, entry: { track, @@ -30,7 +52,7 @@ export default { }, })), - ...artist.tracksAsContributor.map(track => ({ + ...tracksAsContributorOnly.map(track => ({ thing: track, entry: { track, @@ -102,8 +124,9 @@ export default { query.chunks.map(({chunk}) => chunk.map(({contribs}) => contribs - .find(({who}) => who === artist) - .what)), + .filter(({who}) => who === artist) + .filter(({what}) => what) + .map(({what}) => what))), trackRereleases: query.chunks.map(({chunk}) => @@ -166,9 +189,11 @@ export default { }) => item.slots({ otherArtistLinks, - contribution, rerelease, + contribution: + language.formatUnitList(contribution), + content: (duration ? language.$('artistPage.creditList.entry.track.withDuration', { |