diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-23 14:10:12 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-30 20:48:16 -0300 |
commit | 4b38b2227544db2f0420a22f2880c14857cfbecd (patch) | |
tree | 54b93ed02cba4c068a15ca661a09b7a3e723a518 /src/content/dependencies/generateScopedTrackChronologyLinks.js | |
parent | fcfe91f9b032740f44de16b41e4a35a90dbbfa78 (diff) |
content: generateScopedTrackChronologyLinks
Content in generateTrackChronologyLinks is a stub.
Diffstat (limited to 'src/content/dependencies/generateScopedTrackChronologyLinks.js')
-rw-r--r-- | src/content/dependencies/generateScopedTrackChronologyLinks.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/content/dependencies/generateScopedTrackChronologyLinks.js b/src/content/dependencies/generateScopedTrackChronologyLinks.js new file mode 100644 index 00000000..6fc3f6eb --- /dev/null +++ b/src/content/dependencies/generateScopedTrackChronologyLinks.js @@ -0,0 +1,87 @@ +import {sortAlbumsTracksChronologically} from '#sort'; + +import getChronologyRelations from '../util/getChronologyRelations.js'; + +export default { + contentDependencies: [ + 'generateChronologyLinks', + 'linkAlbum', + 'linkArtist', + 'linkTrack', + ], + + relations(relation, album, track) { + const albumFilter = + (album + ? track => track.album === album + : () => true); + + return { + chronologyLinks: + relation('generateChronologyLinks'), + + artistChronologyContributions: + getChronologyRelations(track, { + contributions: [ + ...track.artistContribs ?? [], + ...track.contributorContribs ?? [], + ], + + linkArtist: artist => relation('linkArtist', artist), + linkThing: track => relation('linkTrack', track), + + getThings(artist) { + const getDate = thing => thing.date; + + const things = + ([ + ...artist.tracksAsArtist, + ...artist.tracksAsContributor, + ]).filter(getDate) + .filter(albumFilter); + + return sortAlbumsTracksChronologically(things, {getDate}); + }, + }), + + coverArtistChronologyContributions: + getChronologyRelations(track, { + contributions: track.coverArtistContribs ?? [], + + linkArtist: artist => relation('linkArtist', artist), + + linkThing: trackOrAlbum => + (trackOrAlbum.album + ? relation('linkTrack', trackOrAlbum) + : relation('linkAlbum', trackOrAlbum)), + + getThings(artist) { + const getDate = thing => thing.coverArtDate ?? thing.date; + + const things = + ([ + ...artist.albumsAsCoverArtist, + ...artist.tracksAsCoverArtist, + ]).filter(getDate) + .filter(albumFilter); + + return sortAlbumsTracksChronologically(things, {getDate}); + }, + }), + }; + }, + + generate: (relations) => + relations.chronologyLinks.slots({ + chronologyInfoSets: [ + { + headingString: 'misc.chronology.heading.track', + contributions: relations.artistChronologyContributions, + }, + { + headingString: 'misc.chronology.heading.coverArt', + contributions: relations.coverArtistChronologyContributions, + }, + ], + }), +}; |