« get me outta code hell

content: cut html.template boilerplate - 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-12 16:35:38 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-12 16:35:38 -0300
commit535acb34613b5cf7e22654619f4337b94b70644d (patch)
tree5a713eb4f12eae7e1fe1aa60941709708585db32 /src/content/dependencies/linkContribution.js
parent630af0a345f3be6c3e4aa3300ce138e48ed5ae91 (diff)
content: cut html.template boilerplate
Diffstat (limited to 'src/content/dependencies/linkContribution.js')
-rw-r--r--src/content/dependencies/linkContribution.js71
1 files changed, 31 insertions, 40 deletions
diff --git a/src/content/dependencies/linkContribution.js b/src/content/dependencies/linkContribution.js
index 1d0e2d6..cc0cb35 100644
--- a/src/content/dependencies/linkContribution.js
+++ b/src/content/dependencies/linkContribution.js
@@ -27,48 +27,39 @@ export default {
     return {contribution};
   },
 
-  generate(data, relations, {
-    html,
-    language,
-  }) {
-    return html.template({
-      annotation: 'linkContribution',
-
-      slots: {
-        showContribution: {type: 'boolean', default: false},
-        showIcons: {type: 'boolean', default: false},
-      },
+  slots: {
+    showContribution: {type: 'boolean', default: false},
+    showIcons: {type: 'boolean', default: false},
+  },
 
-      content(slots) {
-        const hasContributionPart = !!(slots.showContribution && data.contribution);
-        const hasExternalPart = !!(slots.showIcons && !empty(relations.artistIcons));
+  generate(data, relations, slots, {html, language}) {
+    const hasContributionPart = !!(slots.showContribution && data.contribution);
+    const hasExternalPart = !!(slots.showIcons && !empty(relations.artistIcons));
 
-        const externalLinks = hasExternalPart &&
-          html.tag('span',
-            {[html.noEdgeWhitespace]: true, class: 'icons'},
-            language.formatUnitList(relations.artistIcons));
+    const externalLinks = hasExternalPart &&
+      html.tag('span',
+        {[html.noEdgeWhitespace]: true, class: 'icons'},
+        language.formatUnitList(relations.artistIcons));
 
-        return (
-          (hasContributionPart
-            ? (hasExternalPart
-                ? language.$('misc.artistLink.withContribution.withExternalLinks', {
-                    artist: relations.artistLink,
-                    contrib: data.contribution,
-                    links: externalLinks,
-                  })
-                : language.$('misc.artistLink.withContribution', {
-                    artist: relations.artistLink,
-                    contrib: data.contribution,
-                  }))
-            : (hasExternalPart
-                ? language.$('misc.artistLink.withExternalLinks', {
-                    artist: relations.artistLink,
-                    links: externalLinks,
-                  })
-                : language.$('misc.artistLink', {
-                    artist: relations.artistLink,
-                  }))));
-      },
-    });
+    return (
+      (hasContributionPart
+        ? (hasExternalPart
+            ? language.$('misc.artistLink.withContribution.withExternalLinks', {
+                artist: relations.artistLink,
+                contrib: data.contribution,
+                links: externalLinks,
+              })
+            : language.$('misc.artistLink.withContribution', {
+                artist: relations.artistLink,
+                contrib: data.contribution,
+              }))
+        : (hasExternalPart
+            ? language.$('misc.artistLink.withExternalLinks', {
+                artist: relations.artistLink,
+                links: externalLinks,
+              })
+            : language.$('misc.artistLink', {
+                artist: relations.artistLink,
+              }))));
   },
 };