diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 14:50:11 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 17:32:58 -0300 |
commit | a7260373aea3ad95ba21e6aba979db0f53e2fe3f (patch) | |
tree | 127def116198b87ef314af47bddba4965a6b3c61 /src/content/dependencies/generateAlbumChronologyLinks.js | |
parent | 31429e48f7f4ce41556dee91165d0729791652e8 (diff) |
content: generateAlbumChronologyLinks
Diffstat (limited to 'src/content/dependencies/generateAlbumChronologyLinks.js')
-rw-r--r-- | src/content/dependencies/generateAlbumChronologyLinks.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/content/dependencies/generateAlbumChronologyLinks.js b/src/content/dependencies/generateAlbumChronologyLinks.js new file mode 100644 index 00000000..3dd7a18e --- /dev/null +++ b/src/content/dependencies/generateAlbumChronologyLinks.js @@ -0,0 +1,53 @@ +import {sortAlbumsTracksChronologically} from '#sort'; + +import getChronologyRelations from '../util/getChronologyRelations.js'; + +export default { + contentDependencies: [ + 'generateChronologyLinks', + 'linkAlbum', + 'linkArtist', + 'linkTrack', + ], + + relations: (relation, album) => ({ + chronologyLinks: + relation('generateChronologyLinks'), + + coverArtistChronologyContributions: + getChronologyRelations(album, { + contributions: album.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.albumCoverArtistContributions, + artist.trackCoverArtistContributions, + ]).flat() + .map(({thing}) => thing) + .filter(getDate); + + return sortAlbumsTracksChronologically(things, {getDate}); + }, + }), + }), + + generate: (relations) => + relations.chronologyLinks.slots({ + chronologyInfoSets: [ + { + headingString: 'misc.chronology.heading.coverArt', + contributions: relations.coverArtistChronologyContributions, + }, + ], + }), +} |