« get me outta code hell

content, data: Divide Flash Lists By Sides - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateTrackFeaturedInFlashesList.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-03-25 11:18:42 -0300
committer(quasar) nebula <qznebula@protonmail.com>2026-03-25 11:18:42 -0300
commit3e5c8f731117b01fdf46c4fe066e1c349dee3827 (patch)
tree503cc42fdb167c2542b8c5b6ec50a06aa112e5bc /src/content/dependencies/generateTrackFeaturedInFlashesList.js
parent263f32444d5158582520615d9d8520bc562e6918 (diff)
content, data: Divide Flash Lists By Sides
Diffstat (limited to 'src/content/dependencies/generateTrackFeaturedInFlashesList.js')
-rw-r--r--src/content/dependencies/generateTrackFeaturedInFlashesList.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/content/dependencies/generateTrackFeaturedInFlashesList.js b/src/content/dependencies/generateTrackFeaturedInFlashesList.js
new file mode 100644
index 00000000..f13368d1
--- /dev/null
+++ b/src/content/dependencies/generateTrackFeaturedInFlashesList.js
@@ -0,0 +1,38 @@
+import {stitchArrays} from '#sugar';
+
+export default {
+  relations: (relation, features, track) => ({
+    flashLinks:
+      features
+        .map(({flash}) => relation('linkFlash', flash)),
+
+    trackLinks:
+      features
+        .map(({as: directlyFeaturedTrack}) =>
+          (directlyFeaturedTrack === track
+            ? null
+         : directlyFeaturedTrack.name === track.name
+            ? null
+            : relation('linkTrack', directlyFeaturedTrack))),
+  }),
+
+  generate: (relations, {html, language}) =>
+    html.tag('ul',
+      {[html.onlyIfContent]: true},
+
+      stitchArrays({
+        flashLink: relations.flashLinks,
+        trackLink: relations.trackLinks,
+      }).map(({flashLink, trackLink}) => {
+          const attributes = html.attributes();
+          const parts = ['flashList.item'];
+          const options = {flash: flashLink};
+
+          if (trackLink) {
+            parts.push('asDifferentRelease');
+            options.track = trackLink;
+          }
+
+          return html.tag('li', attributes, language.$(...parts, options));
+        })),
+};