« 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/generateMusicVideoArtistsLine.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateMusicVideoArtistsLine.js')
-rw-r--r--src/content/dependencies/generateMusicVideoArtistsLine.js46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/content/dependencies/generateMusicVideoArtistsLine.js b/src/content/dependencies/generateMusicVideoArtistsLine.js
index f79fdc8c..54114387 100644
--- a/src/content/dependencies/generateMusicVideoArtistsLine.js
+++ b/src/content/dependencies/generateMusicVideoArtistsLine.js
@@ -6,34 +6,46 @@ export default {
 
   data: (musicVideo) => ({
     label:
-      (musicVideo.label !== 'Music video'
-        ? musicVideo.label
-        : null),
+      musicVideo.label,
   }),
 
   generate: (data, relations, {html, language}) =>
     language.encapsulate('misc.musicVideo.artistsLine', artistsLineCapsule =>
       language.encapsulate(artistsLineCapsule, workingCapsule => {
-        const workingOptions = {[language.onlyIfOptions]: ['credit']};
+        const credit = relations.artistCredit;
 
-        if (data.label) {
-          workingCapsule += '.customLabel';
-          workingOptions.label = data.label;
+        credit.setSlots({
+          normalStringKey:
+            language.encapsulate(artistsLineCapsule, 'credit'),
+
+          showAnnotation: true,
+          showChronology: true,
+
+          chronologyKind: 'musicVideo',
+        });
+
+        if (html.isBlank(credit)) {
+          return html.blank();
         }
 
-        workingOptions.credit =
-          html.tag('span', {class: 'by'},
-            {[html.onlyIfContent]: true},
+        if (data.label === 'Music video' || !data.label) {
+          credit.setSlots({
+            normalStringKey:
+              language.encapsulate(artistsLineCapsule, 'noLabel'),
+          });
 
-            relations.artistCredit.slots({
-              normalStringKey:
-                language.encapsulate(artistsLineCapsule, 'credit'),
+          return credit;
+        }
+
+        const workingOptions = {};
 
-              showAnnotation: true,
-              showChronology: true,
+        workingOptions.credit =
+          html.tag('span', {class: 'by'}, credit);
 
-              chronologyKind: 'musicVideo',
-            }));
+        if (data.label && data.label !== 'Music video') {
+          workingCapsule += '.customLabel';
+          workingOptions.label = data.label;
+        }
 
         return language.$(workingCapsule, workingOptions);
       })),