From ed422988035ce2e67464c544267adce4df4f5f35 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 15 Apr 2023 19:50:02 -0300 Subject: content: generateChronologyLinks, generatePreviousNextLinks --- src/content/util/getChronologyRelations.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/content/util/getChronologyRelations.js (limited to 'src/content/util/getChronologyRelations.js') diff --git a/src/content/util/getChronologyRelations.js b/src/content/util/getChronologyRelations.js new file mode 100644 index 00000000..cdfdef39 --- /dev/null +++ b/src/content/util/getChronologyRelations.js @@ -0,0 +1,19 @@ +export default function getChronologyRelations(thing, { + contributions, + linkArtist, + linkThing, + getThings, +}) { + return contributions.map(({who}) => { + const things = getThings(who); + const index = things.indexOf(thing); + const previous = things[index - 1]; + const next = things[index + 1]; + return { + index: index + 1, + artistLink: linkArtist(who), + previousLink: previous ? linkThing(previous) : null, + nextLink: next ? linkThing(next) : null, + }; + }); +} -- cgit 1.3.0-6-gf8a5