« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateChronologyLinks.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateChronologyLinks.js')
-rw-r--r--src/content/dependencies/generateChronologyLinks.js140
1 files changed, 67 insertions, 73 deletions
diff --git a/src/content/dependencies/generateChronologyLinks.js b/src/content/dependencies/generateChronologyLinks.js
index a61b5e6f..15c0898c 100644
--- a/src/content/dependencies/generateChronologyLinks.js
+++ b/src/content/dependencies/generateChronologyLinks.js
@@ -3,86 +3,80 @@ import {accumulateSum, empty} from '../../util/sugar.js';
 export default {
   extraDependencies: ['html', 'language'],
 
-  generate({html, language}) {
-    return html.template({
-      annotation: `generateChronologyLinks`,
-
-      slots: {
-        chronologyInfoSets: {
-          validate: v =>
-            v.arrayOf(
-              v.validateProperties({
-                headingString: v.isString,
-                contributions: v.arrayOf(v.validateProperties({
-                  index: v.isCountingNumber,
-                  artistLink: v.isHTML,
-                  previousLink: v.isHTML,
-                  nextLink: v.isHTML,
-                })),
-              })),
-        }
-      },
+  slots: {
+    chronologyInfoSets: {
+      validate: v =>
+        v.arrayOf(
+          v.validateProperties({
+            headingString: v.isString,
+            contributions: v.arrayOf(v.validateProperties({
+              index: v.isCountingNumber,
+              artistLink: v.isHTML,
+              previousLink: v.isHTML,
+              nextLink: v.isHTML,
+            })),
+          })),
+    }
+  },
 
-      content(slots) {
-        if (empty(slots.chronologyInfoSets)) {
-          return html.blank();
-        }
+  generate(slots, {html, language}) {
+    if (empty(slots.chronologyInfoSets)) {
+      return html.blank();
+    }
 
-        const totalContributionCount =
-          accumulateSum(
-            slots.chronologyInfoSets,
-            ({contributions}) => contributions.length);
+    const totalContributionCount =
+      accumulateSum(
+        slots.chronologyInfoSets,
+        ({contributions}) => contributions.length);
 
-        if (totalContributionCount === 0) {
-          return html.blank();
-        }
+    if (totalContributionCount === 0) {
+      return html.blank();
+    }
 
-        if (totalContributionCount > 8) {
-          return html.tag('div', {class: 'chronology'},
-            language.$('misc.chronology.seeArtistPages'));
-        }
+    if (totalContributionCount > 8) {
+      return html.tag('div', {class: 'chronology'},
+        language.$('misc.chronology.seeArtistPages'));
+    }
 
-        return html.tags(
-          slots.chronologyInfoSets.map(({
-            headingString,
-            contributions,
-          }) =>
-            contributions.map(({
-              index,
-              artistLink,
-              previousLink,
-              nextLink,
-            }) => {
-              const heading =
-                html.tag('span', {class: 'heading'},
-                  language.$(headingString, {
-                    index: language.formatIndex(index),
-                    artist: artistLink,
-                  }));
+    return html.tags(
+      slots.chronologyInfoSets.map(({
+        headingString,
+        contributions,
+      }) =>
+        contributions.map(({
+          index,
+          artistLink,
+          previousLink,
+          nextLink,
+        }) => {
+          const heading =
+            html.tag('span', {class: 'heading'},
+              language.$(headingString, {
+                index: language.formatIndex(index),
+                artist: artistLink,
+              }));
 
-              const navigation =
-                (previousLink || nextLink) &&
-                  html.tag('span', {class: 'buttons'},
-                    language.formatUnitList([
-                      previousLink?.slots({
-                        tooltip: true,
-                        color: false,
-                        content: language.$('misc.nav.previous'),
-                      }),
+          const navigation =
+            (previousLink || nextLink) &&
+              html.tag('span', {class: 'buttons'},
+                language.formatUnitList([
+                  previousLink?.slots({
+                    tooltip: true,
+                    color: false,
+                    content: language.$('misc.nav.previous'),
+                  }),
 
-                      nextLink?.slots({
-                        tooltip: true,
-                        color: false,
-                        content: language.$('misc.nav.next'),
-                      }),
-                    ].filter(Boolean)));
+                  nextLink?.slots({
+                    tooltip: true,
+                    color: false,
+                    content: language.$('misc.nav.next'),
+                  }),
+                ].filter(Boolean)));
 
-              return html.tag('div', {class: 'chronology'},
-                (navigation
-                  ? language.$('misc.chronology.withNavigation', {heading, navigation})
-                  : heading));
-            })));
-      },
-    });
+          return html.tag('div', {class: 'chronology'},
+            (navigation
+              ? language.$('misc.chronology.withNavigation', {heading, navigation})
+              : heading));
+        })));
   },
 };