diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-23 14:02:19 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-30 20:48:16 -0300 |
commit | fcfe91f9b032740f44de16b41e4a35a90dbbfa78 (patch) | |
tree | f9b50530c3b5a50cebc1c26b090d233be4dfbc9b | |
parent | 887a00f2d7a855348889226e0bc00d989ade1f3a (diff) |
content: generateTrackChronologyLinks
Just extracts logic from generateTrackInfoPage, for now.
-rw-r--r-- | src/content/dependencies/generateTrackChronologyLinks.js | 75 | ||||
-rw-r--r-- | src/content/dependencies/generateTrackInfoPage.js | 70 |
2 files changed, 80 insertions, 65 deletions
diff --git a/src/content/dependencies/generateTrackChronologyLinks.js b/src/content/dependencies/generateTrackChronologyLinks.js new file mode 100644 index 00000000..814e9a6a --- /dev/null +++ b/src/content/dependencies/generateTrackChronologyLinks.js @@ -0,0 +1,75 @@ +import {sortAlbumsTracksChronologically} from '#sort'; + +import getChronologyRelations from '../util/getChronologyRelations.js'; + +export default { + contentDependencies: [ + 'generateChronologyLinks', + 'linkArtist', + 'linkTrack', + ], + + 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); + + 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/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index f5324519..ae4ca621 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -1,9 +1,6 @@ -import {sortAlbumsTracksChronologically, sortFlashesChronologically} - from '#sort'; +import {sortFlashesChronologically} from '#sort'; import {empty, stitchArrays} from '#sugar'; -import getChronologyRelations from '../util/getChronologyRelations.js'; - export default { contentDependencies: [ 'generateAbsoluteDatetimestamp', @@ -12,7 +9,6 @@ export default { 'generateAlbumSecondaryNav', 'generateAlbumSidebar', 'generateAlbumStyleRules', - 'generateChronologyLinks', 'generateColorStyleAttribute', 'generateCommentarySection', 'generateContentHeading', @@ -20,13 +16,13 @@ export default { 'generatePageLayout', 'generateRelativeDatetimestamp', 'generateTrackAdditionalNamesBox', + 'generateTrackChronologyLinks', 'generateTrackCoverArtwork', 'generateTrackList', 'generateTrackListDividedByGroups', 'generateTrackReleaseInfo', 'generateTrackSocialEmbed', 'linkAlbum', - 'linkArtist', 'linkFlash', 'linkTrack', 'transformContent', @@ -55,51 +51,6 @@ export default { relations.socialEmbed = relation('generateTrackSocialEmbed', track); - relations.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}); - }, - }); - - relations.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); - - return sortAlbumsTracksChronologically(things, {getDate}); - }, - }), - relations.albumLink = relation('linkAlbum', track.album); @@ -109,8 +60,8 @@ export default { relations.albumNavAccent = relation('generateAlbumNavAccent', track.album, track); - relations.chronologyLinks = - relation('generateChronologyLinks'); + relations.trackChronologyLinks = + relation('generateTrackChronologyLinks', track); relations.secondaryNav = relation('generateAlbumSecondaryNav', track.album); @@ -580,18 +531,7 @@ export default { }), navContent: - relations.chronologyLinks.slots({ - chronologyInfoSets: [ - { - headingString: 'misc.chronology.heading.track', - contributions: relations.artistChronologyContributions, - }, - { - headingString: 'misc.chronology.heading.coverArt', - contributions: relations.coverArtistChronologyContributions, - }, - ], - }), + relations.trackChronologyLinks, secondaryNav: relations.secondaryNav |