« get me outta code hell

content: generateContributionList - 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>2023-08-10 10:54:41 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-10 10:54:41 -0300
commit84757d1e54f9cb8825b041368b55e01ba0d4b17b (patch)
treee4a7e3379c6a523762307e95a211300c5e42938a
parentf49326e998f69931b52969c4235b0ee478ddc682 (diff)
content: generateContributionList
-rw-r--r--src/content/dependencies/generateContributionList.js20
-rw-r--r--src/content/dependencies/generateTrackInfoPage.js16
2 files changed, 24 insertions, 12 deletions
diff --git a/src/content/dependencies/generateContributionList.js b/src/content/dependencies/generateContributionList.js
new file mode 100644
index 00000000..731cfba5
--- /dev/null
+++ b/src/content/dependencies/generateContributionList.js
@@ -0,0 +1,20 @@
+export default {
+  contentDependencies: ['linkContribution'],
+  extraDependencies: ['html'],
+
+  relations: (relation, contributions) =>
+    ({contributionLinks:
+        contributions
+          .map(contrib => relation('linkContribution', contrib))}),
+
+  generate: (relations, {html}) =>
+    html.tag('ul',
+      relations.contributionLinks.map(contributionLink =>
+        html.tag('li',
+          contributionLink
+            .slots({
+              showIcons: true,
+              showContribution: true,
+              preventWrapping: false,
+            })))),
+};
diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js
index e02a2e3b..742f3902 100644
--- a/src/content/dependencies/generateTrackInfoPage.js
+++ b/src/content/dependencies/generateTrackInfoPage.js
@@ -16,6 +16,7 @@ export default {
     'generateAlbumStyleRules',
     'generateChronologyLinks',
     'generateContentHeading',
+    'generateContributionList',
     'generatePageLayout',
     'generateTrackCoverArtwork',
     'generateTrackList',
@@ -24,7 +25,6 @@ export default {
     'generateTrackSocialEmbed',
     'linkAlbum',
     'linkArtist',
-    'linkContribution',
     'linkFlash',
     'linkTrack',
     'transformContent',
@@ -149,9 +149,8 @@ export default {
       contributors.heading =
         relation('generateContentHeading');
 
-      contributors.contributionLinks =
-        track.contributorContribs
-          .map(contrib => relation('linkContribution', contrib));
+      contributors.list =
+        relation('generateContributionList', track.contributorContribs);
     }
 
     // Section: Referenced tracks
@@ -369,14 +368,7 @@ export default {
                 title: language.$('releaseInfo.contributors'),
               }),
 
-            html.tag('ul',
-              sec.contributors.contributionLinks.map(contributionLink =>
-                html.tag('li',
-                  contributionLink
-                    .slots({
-                      showIcons: true,
-                      showContribution: true,
-                    })))),
+            sec.contributors.list,
           ],
 
           sec.references && [