« 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/generateMusicVideoContributors.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateMusicVideoContributors.js')
-rw-r--r--src/content/dependencies/generateMusicVideoContributors.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/content/dependencies/generateMusicVideoContributors.js b/src/content/dependencies/generateMusicVideoContributors.js
new file mode 100644
index 00000000..fd88745a
--- /dev/null
+++ b/src/content/dependencies/generateMusicVideoContributors.js
@@ -0,0 +1,58 @@
+const contributionSlots = {
+  showAnnotation: true,
+  showChronology: true,
+  showExternalLinks: true,
+  chronologyKind: 'musicVideoContribution',
+};
+
+export default {
+  relations: (relation, musicVideo) => ({
+    artistCredit:
+      relation('generateArtistCredit', musicVideo.contributorContribs, []),
+
+    contributionLinks:
+      musicVideo.contributorContribs
+        .map(contrib => relation('linkContribution', contrib)),
+  }),
+
+  data: (musicVideo) => ({
+    style:
+      musicVideo.contributorStyle,
+  }),
+
+  generate: (data, relations, {html, language}) =>
+    language.encapsulate('misc.musicVideo', capsule =>
+      (data.style === 'list'
+        ? html.tag('p',
+            {[html.joinChildren]: html.tag('br')},
+            {[html.onlyIfContent]: true},
+
+            [
+              html.tags([
+                language.$(capsule, 'contributorsList.title'),
+              ], {[html.onlyIfSiblings]: true}),
+
+              relations.contributionLinks
+                .map(link => link.slots({...contributionSlots})),
+            ])
+
+     : data.style === 'line'
+        ? html.tag('p',
+            {[html.onlyIfContent]: true},
+
+              language.$(capsule, 'contributorsLine', {
+                [language.onlyIfOptions]: ['credit'],
+
+                credit:
+                  relations.artistCredit.slots({
+                    normalStringKey:
+                      language.encapsulate(capsule, 'contributorsLine.credit'),
+
+                    chunkwrap: false,
+
+                    ...contributionSlots,
+                  }),
+              }))
+
+        : html.blank())),
+};