« 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/generateContributionLinks.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateContributionLinks.js')
-rw-r--r--src/content/dependencies/generateContributionLinks.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/content/dependencies/generateContributionLinks.js b/src/content/dependencies/generateContributionLinks.js
index a79c823..18bc409 100644
--- a/src/content/dependencies/generateContributionLinks.js
+++ b/src/content/dependencies/generateContributionLinks.js
@@ -3,37 +3,40 @@ import {empty} from '../../util/sugar.js';
 export default {
   contentDependencies: [
     'linkArtist',
+    'generateIconForURL',
   ],
 
   extraDependencies: [
     'html',
-    'iconifyURL',
     'language',
   ],
 
-  relations(relation, contributions) {
+  relations(relation, contributions, {showIcons = false} = {}) {
     const relations = {};
 
     relations.artistLinks =
       contributions.map(({who}) => relation('linkArtist', who));
 
+    if (showIcons) {
+      relations.artistIcons =
+        contributions.map(({who}) =>
+          who.urls.map(url =>
+            relation('generateIconForURL', url)));
+    }
+
     return relations;
   },
 
   data(contributions, {
     showContribution = false,
     showIcons = false,
-  }) {
+  } = {}) {
     const data = {};
 
-    data.showContribution = showContribution;
-    data.showIcons = showIcons;
-
     data.contributionData =
       contributions.map(({who, what}) => ({
         hasContributionPart: !!(showContribution && what),
         hasExternalPart: !!(showIcons && !empty(who.urls)),
-        artistUrls: who.urls,
         contribution: showContribution && what,
       }));
 
@@ -42,23 +45,21 @@ export default {
 
   generate(data, relations, {
     html,
-    iconifyURL,
     language,
   }) {
     return language.formatConjunctionList(
       data.contributionData.map(({
         hasContributionPart,
         hasExternalPart,
-        artistUrls,
         contribution,
       }, index) => {
         const artistLink = relations.artistLinks[index];
+        const artistIcons = relations.artistIcons?.[index];
 
         const externalLinks = hasExternalPart &&
           html.tag('span',
             {[html.noEdgeWhitespace]: true, class: 'icons'},
-            language.formatUnitList(
-              artistUrls.map(url => iconifyURL(url, {language}))));
+            language.formatUnitList(artistIcons));
 
         return (
           (hasContributionPart