diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 14:50:11 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-18 22:56:09 -0300 |
commit | dc0b29d087aa335a8ffd97f7cbe1f22b2f115f09 (patch) | |
tree | 9127353a118b4727c72dd266d48776777bd108d1 /src/content/dependencies/generateAlbumChronologyLinks.js | |
parent | 50869c28f76cd05c37ce4c5c2f56f52277397c59 (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, + }, + ], + }), +} |