diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-04-15 19:50:02 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-04-15 19:50:02 -0300 |
commit | ed422988035ce2e67464c544267adce4df4f5f35 (patch) | |
tree | 3e89b89301cb5bab4e9558c9f9ad6343bec850e1 /src/content/util | |
parent | 60e85440588fa9c52ae2d856c1e53126935222a4 (diff) |
content: generateChronologyLinks, generatePreviousNextLinks
Diffstat (limited to 'src/content/util')
-rw-r--r-- | src/content/util/getChronologyRelations.js | 19 |
1 files changed, 19 insertions, 0 deletions
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, + }; + }); +} |