« get me outta code hell

content: filter out & cleanly handle dateless things in chronology - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/util/getChronologyRelations.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-02-14 12:35:06 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-14 13:26:47 -0400
commit9b13c1eb3766aeec4be518a755b209d6e0cdfd42 (patch)
tree166acab41bc1ca7a385170731dcdfeaa83ecafbd /src/content/util/getChronologyRelations.js
parent7aa6747fd8b29e2690ff3522fac731081b2b8946 (diff)
content: filter out & cleanly handle dateless things in chronology
Diffstat (limited to 'src/content/util/getChronologyRelations.js')
-rw-r--r--src/content/util/getChronologyRelations.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/content/util/getChronologyRelations.js b/src/content/util/getChronologyRelations.js
index 036c558..67d6d5f 100644
--- a/src/content/util/getChronologyRelations.js
+++ b/src/content/util/getChronologyRelations.js
@@ -29,13 +29,22 @@ export default function getChronologyRelations(thing, {
 
   return contributions.map(({who}) => {
     const things = Array.from(new Set(getThings(who)));
-    if (things.length === 1) {
+
+    // 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).
+    const index = things.indexOf(thing);
+    if (index === -1) {
       return;
     }
 
-    const index = things.indexOf(thing);
+    // 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),