« get me outta code hell

content: generateArtistInfoPageFlashesChunkedList - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateArtistInfoPageChunk.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-27 21:21:14 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-27 21:21:14 -0300
commitecde71b903a89607bf8c5032a1cda61a3ff1b3c5 (patch)
tree0359750c2fcafe28e6a1e883113e4f219e84eae3 /src/content/dependencies/generateArtistInfoPageChunk.js
parentd3f13b864dddec7ef191aca769794695323ed498 (diff)
content: generateArtistInfoPageFlashesChunkedList
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageChunk.js')
-rw-r--r--src/content/dependencies/generateArtistInfoPageChunk.js67
1 files changed, 52 insertions, 15 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageChunk.js b/src/content/dependencies/generateArtistInfoPageChunk.js
index 121cf43d..eb9056cb 100644
--- a/src/content/dependencies/generateArtistInfoPageChunk.js
+++ b/src/content/dependencies/generateArtistInfoPageChunk.js
@@ -2,9 +2,17 @@ export default {
   extraDependencies: ['html', 'language'],
 
   slots: {
+    mode: {
+      validate: v => v.is('flash', 'album'),
+    },
+
     albumLink: {type: 'html'},
+    flashActLink: {type: 'html'},
 
     date: {validate: v => v.isDate},
+    dateRangeStart: {validate: v => v.isDate},
+    dateRangeEnd: {validate: v => v.isDate},
+
     duration: {validate: v => v.isDuration},
     durationApproximate: {type: 'boolean'},
 
@@ -12,26 +20,55 @@ export default {
   },
 
   generate(slots, {html, language}) {
-    let accentedLink = slots.albumLink;
+    let accentedLink;
 
     accent: {
-      const options = {album: accentedLink};
-      const parts = ['artistPage.creditList.album'];
+      switch (slots.mode) {
+        case 'album': {
+          accentedLink = slots.albumLink;
 
-      if (slots.date) {
-        parts.push('withDate');
-        options.date = language.formatDate(slots.date);
-      }
+          const options = {album: accentedLink};
+          const parts = ['artistPage.creditList.album'];
 
-      if (slots.duration) {
-        parts.push('withDuration');
-        options.duration =
-          language.formatDuration(slots.duration, {
-            approximate: slots.durationApproximate,
-          });
-      }
+          if (slots.date) {
+            parts.push('withDate');
+            options.date = language.formatDate(slots.date);
+          }
+
+          if (slots.duration) {
+            parts.push('withDuration');
+            options.duration =
+              language.formatDuration(slots.duration, {
+                approximate: slots.durationApproximate,
+              });
+          }
 
-      accentedLink = language.formatString(parts.join('.'), options);
+          accentedLink = language.formatString(parts.join('.'), options);
+          break;
+        }
+
+        case 'flash': {
+          accentedLink = slots.flashActLink;
+
+          const options = {act: accentedLink};
+          const parts = ['artistPage.creditList.flashAct'];
+
+          if (
+            slots.dateRangeStart &&
+            slots.dateRangeEnd &&
+            slots.dateRangeStart !== slots.dateRangeEnd
+          ) {
+            parts.push('withDateRange');
+            options.dateRange = language.formatDateRange(slots.dateRangeStart, slots.dateRangeEnd);
+          } else if (slots.dateRangeStart || slots.date) {
+            parts.push('withDate');
+            options.date = language.formatDate(slots.dateFirst);
+          }
+
+          accentedLink = language.formatString(parts.join('.'), options);
+          break;
+        }
+      }
     }
 
     return html.tags([