« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateTrackList.js80
1 files changed, 36 insertions, 44 deletions
diff --git a/src/content/dependencies/generateTrackList.js b/src/content/dependencies/generateTrackList.js
index 3c36d248..4760ff2f 100644
--- a/src/content/dependencies/generateTrackList.js
+++ b/src/content/dependencies/generateTrackList.js
@@ -5,55 +5,47 @@ export default {
 
   extraDependencies: ['html', 'language'],
 
-  relations(relation, tracks) {
-    if (empty(tracks)) {
-      return {};
-    }
+  relations: (relation, tracks) => ({
+    trackLinks:
+      tracks
+        .map(track => relation('linkTrack', track)),
 
-    return {
-      trackLinks:
-        tracks
-          .map(track => relation('linkTrack', track)),
-
-      contributionLinks:
-        tracks
-          .map(track =>
-            (empty(track.artistContribs)
-              ? null
-              : track.artistContribs
-                  .map(contrib => relation('linkContribution', contrib)))),
-    };
-  },
+    contributionLinks:
+      tracks
+        .map(track =>
+          track.artistContribs
+            .map(contrib => relation('linkContribution', contrib))),
+  }),
 
   slots: {
     showContribution: {type: 'boolean', default: false},
     showIcons: {type: 'boolean', default: false},
   },
 
-  generate(relations, slots, {html, language}) {
-    return (
-      html.tag('ul',
-        stitchArrays({
-          trackLink: relations.trackLinks,
-          contributionLinks: relations.contributionLinks,
-        }).map(({trackLink, contributionLinks}) =>
-            html.tag('li',
-              (empty(contributionLinks)
-                ? trackLink
-                : language.$('trackList.item.withArtists', {
-                    track: trackLink,
-                    by:
-                      html.tag('span', {class: 'by'},
-                        html.metatag('chunkwrap', {split: ','},
-                          language.$('trackList.item.withArtists.by', {
-                            artists:
-                              language.formatConjunctionList(
-                                contributionLinks.map(link =>
-                                  link.slots({
-                                    showContribution: slots.showContribution,
-                                    showIcons: slots.showIcons,
-                                  }))),
-                          }))),
-                  }))))));
-  },
+  generate: (relations, slots, {html, language}) =>
+    html.tag('ul',
+      {[html.onlyIfContent]: true},
+
+      stitchArrays({
+        trackLink: relations.trackLinks,
+        contributionLinks: relations.contributionLinks,
+      }).map(({trackLink, contributionLinks}) =>
+          html.tag('li',
+            (empty(contributionLinks)
+              ? trackLink
+              : language.$('trackList.item.withArtists', {
+                  track: trackLink,
+                  by:
+                    html.tag('span', {class: 'by'},
+                      html.metatag('chunkwrap', {split: ','},
+                        language.$('trackList.item.withArtists.by', {
+                          artists:
+                            language.formatConjunctionList(
+                              contributionLinks.map(link =>
+                                link.slots({
+                                  showContribution: slots.showContribution,
+                                  showIcons: slots.showIcons,
+                                }))),
+                        }))),
+                }))))),
 };