From a7260373aea3ad95ba21e6aba979db0f53e2fe3f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 12 Jun 2024 14:50:11 -0300 Subject: content: generateAlbumChronologyLinks --- .../dependencies/generateAlbumChronologyLinks.js | 53 ++++++++++++++++++++++ src/content/dependencies/generateAlbumInfoPage.js | 43 ++---------------- src/content/dependencies/generateTrackInfoPage.js | 4 +- 3 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 src/content/dependencies/generateAlbumChronologyLinks.js (limited to 'src/content') 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, + }, + ], + }), +} diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js index 02854a16..1d0f6549 100644 --- a/src/content/dependencies/generateAlbumInfoPage.js +++ b/src/content/dependencies/generateAlbumInfoPage.js @@ -1,8 +1,5 @@ -import {sortAlbumsTracksChronologically} from '#sort'; import {empty} from '#sugar'; -import getChronologyRelations from '../util/getChronologyRelations.js'; - export default { contentDependencies: [ 'generateAlbumAdditionalFilesList', @@ -15,14 +12,13 @@ export default { 'generateAlbumSocialEmbed', 'generateAlbumStyleRules', 'generateAlbumTrackList', - 'generateChronologyLinks', + 'generateAlbumChronologyLinks', 'generateCommentarySection', 'generateContentHeading', 'generatePageLayout', 'linkAlbum', 'linkAlbumCommentary', 'linkAlbumGallery', - 'linkArtist', 'linkTrack', 'transformContent', ], @@ -42,37 +38,11 @@ export default { relations.socialEmbed = relation('generateAlbumSocialEmbed', album); - relations.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}); - }, - }); - relations.albumNavAccent = relation('generateAlbumNavAccent', album, null); relations.chronologyLinks = - relation('generateChronologyLinks'); + relation('generateAlbumChronologyLinks', album); relations.secondaryNav = relation('generateAlbumSecondaryNav', album); @@ -249,14 +219,7 @@ export default { ], navContent: - relations.chronologyLinks.slots({ - chronologyInfoSets: [ - { - headingString: 'misc.chronology.heading.coverArt', - contributions: relations.coverArtistChronologyContributions, - }, - ], - }), + relations.chronologyLinks, banner: relations.banner ?? null, bannerPosition: 'top', diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index bffebe07..1cbbc8a8 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -49,7 +49,7 @@ export default { albumNavAccent: relation('generateAlbumNavAccent', track.album, track), - trackChronologyLinks: + chronologyLinks: relation('generateTrackChronologyLinks', track), secondaryNav: @@ -369,7 +369,7 @@ export default { }), navContent: - relations.trackChronologyLinks, + relations.chronologyLinks, secondaryNav: relations.secondaryNav -- cgit 1.3.0-6-gf8a5