« 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.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/content/dependencies/generateMusicVideoArtistsLine.js b/src/content/dependencies/generateMusicVideoArtistsLine.js
new file mode 100644
index 00000000..f79fdc8c
--- /dev/null
+++ b/src/content/dependencies/generateMusicVideoArtistsLine.js
@@ -0,0 +1,40 @@
+export default {
+  relations: (relation, musicVideo) => ({
+    artistCredit:
+      relation('generateArtistCredit', musicVideo.artistContribs, []),
+  }),
+
+  data: (musicVideo) => ({
+    label:
+      (musicVideo.label !== 'Music video'
+        ? musicVideo.label
+        : null),
+  }),
+
+  generate: (data, relations, {html, language}) =>
+    language.encapsulate('misc.musicVideo.artistsLine', artistsLineCapsule =>
+      language.encapsulate(artistsLineCapsule, workingCapsule => {
+        const workingOptions = {[language.onlyIfOptions]: ['credit']};
+
+        if (data.label) {
+          workingCapsule += '.customLabel';
+          workingOptions.label = data.label;
+        }
+
+        workingOptions.credit =
+          html.tag('span', {class: 'by'},
+            {[html.onlyIfContent]: true},
+
+            relations.artistCredit.slots({
+              normalStringKey:
+                language.encapsulate(artistsLineCapsule, 'credit'),
+
+              showAnnotation: true,
+              showChronology: true,
+
+              chronologyKind: 'musicVideo',
+            }));
+
+        return language.$(workingCapsule, workingOptions);
+      })),
+};