diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-04-27 15:39:55 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-04-27 15:39:55 -0300 |
commit | 878a96cb223783ef1b100fdb3bb9d795404c44f5 (patch) | |
tree | 955e9a4bc2c6efcab315205a98fe19bf82e0212b /src | |
parent | 7233eeffbbb5fe02113ea7e18322eaeec520f79e (diff) |
sort art galleries reverse-chronologically (again)
Fixes #170.
Diffstat (limited to 'src')
-rw-r--r-- | src/page/artist.js | 2 | ||||
-rw-r--r-- | src/util/wiki-data.js | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/page/artist.js b/src/page/artist.js index 87859c89..29e4aba6 100644 --- a/src/page/artist.js +++ b/src/page/artist.js @@ -40,7 +40,7 @@ export function write(artist, {wikiData}) { ...(artist.albumsAsCoverArtist ?? []), ...(artist.tracksAsCoverArtist ?? []), ], - {getDate: (o) => o.coverArtDate}); + {latestFirst: true, getDate: (o) => o.coverArtDate}); const commentaryThings = sortAlbumsTracksChronologically([ ...(artist.albumsAsCommentator ?? []), diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js index 0eb86a1e..5a0e241a 100644 --- a/src/util/wiki-data.js +++ b/src/util/wiki-data.js @@ -316,6 +316,7 @@ export function sortChronologically(data, { // // This function also works for data lists which contain only tracks. export function sortAlbumsTracksChronologically(data, { + latestFirst = false, getDate, } = {}) { // Sort albums before tracks... @@ -333,7 +334,18 @@ export function sortAlbumsTracksChronologically(data, { // released on the same date, they'll still be grouped together by album, // and tracks within an album will retain their relative positioning (i.e. // stay in the same order as part of the album's track listing). - sortByDate(data, {getDate}); + + if (latestFirst) { + // Like in sortChronologically, double reverse: Since we reverse after + // sorting by date, also reverse before, so that items with the same date + // are flipped relative to each other twice - that maintains the original + // relative ordering! + data.reverse(); + sortByDate(data, {getDate}); + data.reverse(); + } else { + sortByDate(data, {getDate}); + } return data; } |