From 9d655c9a4c910a9dc02eceb850d393832a105fba Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 23 Apr 2024 16:41:33 -0300 Subject: content: generateChronologyLinks: sort most-to-least --- src/content/dependencies/generateChronologyLinks.js | 13 +++++++------ src/content/util/getChronologyRelations.js | 7 ++++++- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/content/dependencies/generateChronologyLinks.js b/src/content/dependencies/generateChronologyLinks.js index bd798849..19c33be6 100644 --- a/src/content/dependencies/generateChronologyLinks.js +++ b/src/content/dependencies/generateChronologyLinks.js @@ -19,6 +19,7 @@ export default { artistLink: v.isHTML, previousLink: v.isHTML, nextLink: v.isHTML, + only: v.isBoolean, })), })), } @@ -37,8 +38,7 @@ export default { ...entry, contributions: contributions - .filter(({nextLink, previousLink}) => - nextLink || previousLink), + .filter(({only}) => !only), })) .filter(({contributions}) => !empty(contributions)); } @@ -67,20 +67,21 @@ export default { artistLink, previousLink, nextLink, + only, }) => { const heading = html.tag('span', {class: 'heading'}, language.$(headingString, { index: - (previousLink || nextLink - ? language.formatIndex(index) - : language.formatString('misc.chronology.heading.onlyIndex')), + (only + ? language.formatString('misc.chronology.heading.onlyIndex') + : language.formatIndex(index)), artist: artistLink, })); const navigation = - (previousLink || nextLink) && + !only && html.tag('span', {class: 'buttons'}, language.formatUnitList([ previousLink?.slots({ diff --git a/src/content/util/getChronologyRelations.js b/src/content/util/getChronologyRelations.js index 7a67c6f9..e4475ff8 100644 --- a/src/content/util/getChronologyRelations.js +++ b/src/content/util/getChronologyRelations.js @@ -45,6 +45,11 @@ export default function getChronologyRelations(thing, { artistLink: linkArtist(artist), previousLink: previous ? linkThing(previous) : null, nextLink: next ? linkThing(next) : null, + only: !(previous || next), }; - }).filter(Boolean); + }).filter(Boolean) + .sort((a, b) => + (a.only === b.only ? b.index - a.index + : a.only ? +1 + : -1)) } -- cgit 1.3.0-6-gf8a5