« get me outta code hell

content: linkContribution: take standard {who, what} object - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkContribution.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-24 17:55:00 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-24 17:55:00 -0300
commit64b4a5e6355872c49429f1d19c3403277d032b6c (patch)
treef7224646e1e9027e57df895648d54ac132005677 /src/content/dependencies/linkContribution.js
parent0020a0de027d04607c7765c84b891750dc35f41b (diff)
content: linkContribution: take standard {who, what} object
This is what's used for all contributions anyway, so no need to
have every call to linkContribution manually destructure whatever
contribution is being provided.
Diffstat (limited to 'src/content/dependencies/linkContribution.js')
-rw-r--r--src/content/dependencies/linkContribution.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index c9b514f..f4c0538 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -11,14 +11,15 @@ export default {
     'language',
   ],
 
-  relations(relation, artist) {
+  relations(relation, contribution) {
     const relations = {};
 
-    relations.artistLink = relation('linkArtist', artist);
+    relations.artistLink =
+      relation('linkArtist', contribution.who);
 
-    if (!empty(artist.urls)) {
+    if (!empty(contribution.who.urls)) {
       relations.artistIcons =
-        artist.urls
+        contribution.who.urls
           .slice(0, 4)
           .map(url => relation('linkExternalAsIcon', url));
     }
@@ -26,8 +27,10 @@ export default {
     return relations;
   },
 
-  data(artist, contribution) {
-    return {contribution};
+  data(contribution) {
+    return {
+      what: contribution.what,
+    };
   },
 
   slots: {
@@ -36,7 +39,7 @@ export default {
   },
 
   generate(data, relations, slots, {html, language}) {
-    const hasContributionPart = !!(slots.showContribution && data.contribution);
+    const hasContributionPart = !!(slots.showContribution && data.what);
     const hasExternalPart = !!(slots.showIcons && relations.artistIcons);
 
     const externalLinks = hasExternalPart &&
@@ -49,7 +52,7 @@ export default {
 
     if (hasContributionPart) {
       parts.push('withContribution');
-      options.contrib = data.contribution;
+      options.contrib = data.what;
     }
 
     if (hasExternalPart) {