From 9ff95d1c338d8a194c91d90b3f8fccf59442da03 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 2 Aug 2021 16:15:57 -0300 Subject: fix misordered art lists & chronology links --- src/misc-templates.js | 3 ++- src/page/album.js | 1 + src/page/artist.js | 4 ++-- src/util/wiki-data.js | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/misc-templates.js b/src/misc-templates.js index d4e4af3..139978d 100644 --- a/src/misc-templates.js +++ b/src/misc-templates.js @@ -45,6 +45,7 @@ export function getArtistString(artists, { // Chronology links export function generateChronologyLinks(currentThing, { + dateKey = 'date', contribKey, getThings, headingString, @@ -65,7 +66,7 @@ export function generateChronologyLinks(currentThing, { } return contributions.map(({ who: artist }) => { - const things = sortByDate(unique(getThings(artist))); + const things = sortByDate(unique(getThings(artist)), dateKey); const releasedThings = things.filter(thing => { const album = albumData.includes(thing) ? thing : thing.album; return !(album && album.directory === UNRELEASED_TRACKS_DIRECTORY); diff --git a/src/page/album.js b/src/page/album.js index adcc058..19efc70 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -394,6 +394,7 @@ export function generateAlbumChronologyLinks(album, currentTrack, {generateChron }), generateChronologyLinks(currentTrack || album, { contribKey: 'coverArtists', + dateKey: 'coverArtDate', getThings: artist => [...artist.albums.asCoverArtist, ...artist.tracks.asCoverArtist], headingString: 'misc.chronology.heading.coverArt' }) diff --git a/src/page/artist.js b/src/page/artist.js index 695fddf..2e87669 100644 --- a/src/page/artist.js +++ b/src/page/artist.js @@ -51,7 +51,7 @@ export function write(artist, {wikiData}) { key }); - const artListChunks = chunkByProperties(artThingsAll.flatMap(thing => + const artListChunks = chunkByProperties(sortByDate(artThingsAll.flatMap(thing => (['coverArtists', 'wallpaperArtists', 'bannerArtists'] .map(key => getArtistsAndContrib(thing, key)) .filter(({ contrib }) => contrib) @@ -61,7 +61,7 @@ export function write(artist, {wikiData}) { date: +(thing.coverArtDate || thing.date), ...props }))) - ), ['date', 'album']); + )), ['date', 'album']); const commentaryListChunks = chunkByProperties(commentaryThings.map(thing => ({ album: thing.album || thing, diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js index 87c4b22..3f24e6a 100644 --- a/src/util/wiki-data.js +++ b/src/util/wiki-data.js @@ -79,11 +79,11 @@ export function sortByName(a, b) { // This function was originally made to sort just al8um data, 8ut its exact // code works fine for sorting tracks too, so I made the varia8les and names // more general. -export function sortByDate(data) { +export function sortByDate(data, dateKey = 'date') { // Just to 8e clear: sort is a mutating function! I only return the array // 8ecause then you don't have to define it as a separate varia8le 8efore // passing it into this function. - return data.sort((a, b) => a.date - b.date); + return data.sort((a, b) => a[dateKey] - b[dateKey]); } // Same details as the sortByDate, 8ut for covers~ -- cgit 1.3.0-6-gf8a5