« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateAlbumTrackListItem.js35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/content/dependencies/generateAlbumTrackListItem.js b/src/content/dependencies/generateAlbumTrackListItem.js
index 761a4b50..794c4201 100644
--- a/src/content/dependencies/generateAlbumTrackListItem.js
+++ b/src/content/dependencies/generateAlbumTrackListItem.js
@@ -37,28 +37,29 @@ export default {
   },
 
   generate(data, relations, {getColors, html, language}) {
-    const stringOpts = {
-      duration: language.formatDuration(data.duration),
-      track: relations.trackLink,
-    };
-
     let style;
+
     if (data.color) {
       const {primary} = getColors(data.color);
       style = `--primary-color: ${primary}`;
     }
 
-    return html.tag('li',
-      {style},
-      (!data.showArtists
-        ? language.$('trackList.item.withDuration', stringOpts)
-        : language.$('trackList.item.withDuration.withArtists', {
-            ...stringOpts,
-            by:
-              html.tag('span', {class: 'by'},
-                language.$('trackList.item.withArtists.by', {
-                  artists: language.formatConjunctionList(relations.contributionLinks),
-                })),
-          })));
+    const parts = ['trackList.item.withDuration'];
+    const options = {};
+
+    options.duration = language.formatDuration(data.duration);
+    options.track = relations.trackLink;
+
+    if (data.showArtists) {
+      parts.push('withArtists');
+      options.by =
+        html.tag('span', {class: 'by'},
+          language.$('trackList.item.withArtists.by', {
+            artists: language.formatConjunctionList(relations.contributionLinks),
+          }));
+    }
+
+    return html.tag('li', {style},
+      language.formatString(parts.join('.'), options));
   },
 };