From 4b38b2227544db2f0420a22f2880c14857cfbecd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 23 Apr 2024 14:10:12 -0300 Subject: content: generateScopedTrackChronologyLinks Content in generateTrackChronologyLinks is a stub. --- .../generateScopedTrackChronologyLinks.js | 87 ++++++++++++++++++++++ .../dependencies/generateTrackChronologyLinks.js | 79 +++----------------- 2 files changed, 98 insertions(+), 68 deletions(-) create mode 100644 src/content/dependencies/generateScopedTrackChronologyLinks.js (limited to 'src/content') 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, + }, + ], + }), +}; diff --git a/src/content/dependencies/generateTrackChronologyLinks.js b/src/content/dependencies/generateTrackChronologyLinks.js index 814e9a6a..ba4428a5 100644 --- a/src/content/dependencies/generateTrackChronologyLinks.js +++ b/src/content/dependencies/generateTrackChronologyLinks.js @@ -1,75 +1,18 @@ -import {sortAlbumsTracksChronologically} from '#sort'; - -import getChronologyRelations from '../util/getChronologyRelations.js'; - export default { - contentDependencies: [ - 'generateChronologyLinks', - 'linkArtist', - 'linkTrack', - ], + contentDependencies: ['generateScopedTrackChronologyLinks'], + extraDependencies: ['html'], relations: (relation, track) => ({ - 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); - - 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); + wikiChronologyLinks: + relation('generateScopedTrackChronologyLinks', null, track), - return sortAlbumsTracksChronologically(things, {getDate}); - }, - }), + albumChronologyLinks: + relation('generateScopedTrackChronologyLinks', track.album, track), }), - generate: (relations) => - relations.chronologyLinks.slots({ - chronologyInfoSets: [ - { - headingString: 'misc.chronology.heading.track', - contributions: relations.artistChronologyContributions, - }, - { - headingString: 'misc.chronology.heading.coverArt', - contributions: relations.coverArtistChronologyContributions, - }, - ], - }), + generate: (relations, {html}) => + html.tags([ + relations.wikiChronologyLinks, + relations.albumChronologyLinks, + ]), }; -- cgit 1.3.0-6-gf8a5