« get me outta code hell

content: generateChronologyLinks: "Only track by..." - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-23 14:44:51 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-05-30 20:48:17 -0300
commitfe8f774aeb51eb9167421a1c5f6356163e04af04 (patch)
tree72cb31e350440c500464b94aa89fc6dcb58bd84b
parent88d6ff83332c4b089a4386efa9cb4469cfef555f (diff)
content: generateChronologyLinks: "Only track by..."
-rw-r--r--src/content/dependencies/generateChronologyLinks.js23
-rw-r--r--src/content/dependencies/generateScopedTrackChronologyLinks.js2
-rw-r--r--src/content/util/getChronologyRelations.js5
-rw-r--r--src/strings-default.yaml1
4 files changed, 23 insertions, 8 deletions
diff --git a/src/content/dependencies/generateChronologyLinks.js b/src/content/dependencies/generateChronologyLinks.js
index 8ec6ee0a..0158ffd5 100644
--- a/src/content/dependencies/generateChronologyLinks.js
+++ b/src/content/dependencies/generateChronologyLinks.js
@@ -4,6 +4,11 @@ export default {
   extraDependencies: ['html', 'language'],
 
   slots: {
+    showOnly: {
+      type: 'boolean',
+      default: false,
+    },
+
     chronologyInfoSets: {
       validate: v =>
         v.strictArrayOf(
@@ -24,9 +29,17 @@ export default {
       return html.blank();
     }
 
+    let infoSets = slots.chronologyInfoSets;
+
+    if (!slots.showOnly) {
+      infoSets = infoSets
+        .filter(({nextLink, previousLink}) =>
+          nextLink || previousLink);
+    }
+
     const totalContributionCount =
       accumulateSum(
-        slots.chronologyInfoSets,
+        infoSets,
         ({contributions}) => contributions.length);
 
     if (totalContributionCount === 0) {
@@ -39,7 +52,7 @@ export default {
     }
 
     return html.tags(
-      slots.chronologyInfoSets.map(({
+      infoSets.map(({
         headingString,
         contributions,
       }) =>
@@ -52,7 +65,11 @@ export default {
           const heading =
             html.tag('span', {class: 'heading'},
               language.$(headingString, {
-                index: language.formatIndex(index),
+                index:
+                  (previousLink || nextLink
+                    ? language.formatIndex(index)
+                    : language.formatString('misc.chronology.heading.onlyIndex')),
+
                 artist: artistLink,
               }));
 
diff --git a/src/content/dependencies/generateScopedTrackChronologyLinks.js b/src/content/dependencies/generateScopedTrackChronologyLinks.js
index fb43203b..7cb9ee63 100644
--- a/src/content/dependencies/generateScopedTrackChronologyLinks.js
+++ b/src/content/dependencies/generateScopedTrackChronologyLinks.js
@@ -96,6 +96,8 @@ export default {
           })),
 
         relations.chronologyLinks.slots({
+          showOnly: true,
+
           chronologyInfoSets: [
             {
               headingString: 'misc.chronology.heading.track',
diff --git a/src/content/util/getChronologyRelations.js b/src/content/util/getChronologyRelations.js
index c4a62dad..7a67c6f9 100644
--- a/src/content/util/getChronologyRelations.js
+++ b/src/content/util/getChronologyRelations.js
@@ -37,13 +37,8 @@ export default function getChronologyRelations(thing, {
       return;
     }
 
-    // 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,
diff --git a/src/strings-default.yaml b/src/strings-default.yaml
index 33c3c829..c1298555 100644
--- a/src/strings-default.yaml
+++ b/src/strings-default.yaml
@@ -490,6 +490,7 @@ misc:
       coverArt: "{INDEX} cover art by {ARTIST}"
       flash: "{INDEX} flash/game by {ARTIST}"
       track: "{INDEX} track by {ARTIST}"
+      onlyIndex: "Only"
 
   # external:
   #   Links which will generally bring you somewhere off of the wiki.