diff options
Diffstat (limited to 'src/content/dependencies')
4 files changed, 92 insertions, 54 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js index a3bcf687..9efd2b14 100644 --- a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js +++ b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js @@ -24,47 +24,58 @@ export default { // shape (#70) and get their own sorting function. Read for more info: // https://github.com/hsmusic/hsmusic-wiki/issues/90#issuecomment-1607422961 - const entries = [ - ...artist.albumsAsCoverArtist.map(album => ({ - thing: album, - entry: { + const processEntries = (things, details) => + things.map(thing => ({ + thing, + entry: details(thing), + })); + + const albumCoverEntries = + processEntries( + artist.albumsAsCoverArtist, + album => ({ type: 'albumCover', album: album, date: album.coverArtDate ?? album.date, contribs: album.coverArtistContribs, - }, - })), + })); - ...artist.albumsAsWallpaperArtist.map(album => ({ - thing: album, - entry: { + const albumWallpaperEntries = + processEntries( + artist.albumsAsWallpaperArtist, + album => ({ type: 'albumWallpaper', album: album, date: album.coverArtDate ?? album.date, contribs: album.wallpaperArtistContribs, - }, - })), + })); - ...artist.albumsAsBannerArtist.map(album => ({ - thing: album, - entry: { + const albumBannerEntries = + processEntries( + artist.albumsAsBannerArtist, + album => ({ type: 'albumBanner', album: album, date: album.coverArtDate ?? album.date, contribs: album.bannerArtistContribs, - }, - })), + })); - ...artist.tracksAsCoverArtist.map(track => ({ - thing: track, - entry: { + const trackCoverEntries = + processEntries( + artist.tracksAsCoverArtist, + track => ({ type: 'trackCover', album: track.album, date: track.coverArtDate ?? track.date, track: track, contribs: track.coverArtistContribs, - }, - })), + })); + + const entries = [ + ...albumCoverEntries, + ...albumWallpaperEntries, + ...albumBannerEntries, + ...trackCoverEntries, ]; sortEntryThingPairs(entries, diff --git a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js index af5a923f..2892152e 100644 --- a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js +++ b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js @@ -18,23 +18,32 @@ export default { extraDependencies: ['html', 'language'], query(artist) { - const entries = [ - ...artist.albumsAsCommentator.map(album => ({ - thing: album, - entry: { + const processEntries = (things, details) => + things.map(thing => ({ + thing, + entry: details(thing), + })); + + const albumEntries = + processEntries( + artist.albumsAsCommentator, + album => ({ type: 'album', album, - }, - })), + })); - ...artist.tracksAsCommentator.map(track => ({ - thing: track, - entry: { + const trackEntries = + processEntries( + artist.tracksAsCommentator, + track => ({ type: 'track', album: track.album, track, - }, - })), + })); + + const entries = [ + ...albumEntries, + ...trackEntries, ]; sortEntryThingPairs(entries, sortAlbumsTracksChronologically); diff --git a/src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js b/src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js index 799e8509..8f02ef9b 100644 --- a/src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js +++ b/src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js @@ -16,15 +16,23 @@ export default { extraDependencies: ['html', 'language'], query(artist) { - const entries = [ - ...artist.flashesAsContributor.map(flash => ({ - thing: flash, - entry: { + const processEntries = (things, details) => + things.map(thing => ({ + thing, + entry: details(thing), + })); + + const contributorEntries = + processEntries( + artist.flashesAsContributor, + flash => ({ flash, act: flash.act, contribs: flash.contributorContribs, - }, - })), + })); + + const entries = [ + ...contributorEntries, ]; sortEntryThingPairs(entries, sortFlashesChronologically); diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js index 654f759c..4ad047b9 100644 --- a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js +++ b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js @@ -19,6 +19,12 @@ export default { extraDependencies: ['html', 'language'], query(artist) { + const processEntries = (things, details) => + things.map(thing => ({ + thing, + entry: details(thing), + })); + const tracksAsArtistAndContributor = artist.tracksAsArtist .filter(track => artist.tracksAsContributor.includes(track)); @@ -31,36 +37,40 @@ export default { artist.tracksAsContributor .filter(track => !artist.tracksAsArtist.includes(track)); - const entries = [ - ...tracksAsArtistAndContributor.map(track => ({ - thing: track, - entry: { + const entriesAsArtistAndContributor = + processEntries( + tracksAsArtistAndContributor, + track => ({ track, album: track.album, date: track.date, contribs: [...track.artistContribs, ...track.contributorContribs], - }, - })), + })); - ...tracksAsArtistOnly.map(track => ({ - thing: track, - entry: { + const entriesAsArtistOnly = + processEntries( + tracksAsArtistOnly, + track => ({ track, album: track.album, date: track.date, contribs: track.artistContribs, - }, - })), + })); - ...tracksAsContributorOnly.map(track => ({ - thing: track, - entry: { + const entriesAsContributorOnly = + processEntries( + tracksAsContributorOnly, + track => ({ track, date: track.date, album: track.album, contribs: track.contributorContribs, - }, - })), + })); + + const entries = [ + ...entriesAsArtistAndContributor, + ...entriesAsArtistOnly, + ...entriesAsContributorOnly, ]; sortEntryThingPairs(entries, sortAlbumsTracksChronologically); |