diff options
Diffstat (limited to 'src/content/util')
-rw-r--r-- | src/content/util/getChronologyRelations.js | 26 | ||||
-rw-r--r-- | src/content/util/groupTracksByGroup.js | 23 |
2 files changed, 14 insertions, 35 deletions
diff --git a/src/content/util/getChronologyRelations.js b/src/content/util/getChronologyRelations.js index 67d6d5fa..c601a990 100644 --- a/src/content/util/getChronologyRelations.js +++ b/src/content/util/getChronologyRelations.js @@ -18,17 +18,17 @@ export default function getChronologyRelations(thing, { const artistsSoFar = new Set(); - contributions = contributions.filter(({who}) => { - if (artistsSoFar.has(who)) { + contributions = contributions.filter(({artist}) => { + if (artistsSoFar.has(artist)) { return false; } else { - artistsSoFar.add(who); + artistsSoFar.add(artist); return true; } }); - return contributions.map(({who}) => { - const things = Array.from(new Set(getThings(who))); + return contributions.map(({artist}) => { + const things = Array.from(new Set(getThings(artist))); // Don't show a line if this contribution isn't part of the artist's // chronology at all (usually because this thing isn't dated). @@ -37,19 +37,21 @@ export default function getChronologyRelations(thing, { return; } - // Don't show a line if this contribution is the *only* item in the - // artist's chronology (since there's nothing to navigate there). const previous = things[index - 1]; const next = things[index + 1]; - if (!previous && !next) { - return; - } return { index: index + 1, - artistLink: linkArtist(who), + artistDirectory: artist.directory, + only: !(previous || next), + + artistLink: linkArtist(artist), previousLink: previous ? linkThing(previous) : null, nextLink: next ? linkThing(next) : null, }; - }).filter(Boolean); + }).filter(Boolean) + .sort((a, b) => + (a.only === b.only ? b.index - a.index + : a.only ? +1 + : -1)) } diff --git a/src/content/util/groupTracksByGroup.js b/src/content/util/groupTracksByGroup.js deleted file mode 100644 index 4e189007..00000000 --- a/src/content/util/groupTracksByGroup.js +++ /dev/null @@ -1,23 +0,0 @@ -import {empty} from '#sugar'; - -export default function groupTracksByGroup(tracks, groups) { - const lists = new Map(groups.map(group => [group, []])); - lists.set('other', []); - - for (const track of tracks) { - const group = groups.find(group => group.albums.includes(track.album)); - if (group) { - lists.get(group).push(track); - } else { - lists.get('other').push(track); - } - } - - for (const [key, tracks] of lists.entries()) { - if (empty(tracks)) { - lists.delete(key); - } - } - - return lists; -} |