« get me outta code hell

getChronologyRelations.js « util « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/util/getChronologyRelations.js
blob: cdfdef3900f14fbb4bee519e15e54dbcc722aa3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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,
    };
  });
}