« get me outta code hell

content: generateTrackList: featuring credits - 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:
author(quasar) nebula <qznebula@protonmail.com>2024-10-20 19:37:33 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-10-20 19:37:33 -0300
commite1171dd824e5d697d78dae996322295b0353ae2a (patch)
treefd1a18d129be89b5e2fa1a18a90498ac5a868389 /src/content
parentb4097b4c12049814a8e350a469972bbe9addd8a6 (diff)
content: generateTrackList: featuring credits
This code is basically copy-pasted from generateAlbumTrackListItem,
maybe it should be a common component??? Probably not.
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateTrackList.js33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/content/dependencies/generateTrackList.js b/src/content/dependencies/generateTrackList.js
index 7c3b11c1..2d6e9a85 100644
--- a/src/content/dependencies/generateTrackList.js
+++ b/src/content/dependencies/generateTrackList.js
@@ -1,7 +1,7 @@
-import {empty, stitchArrays} from '#sugar';
+import {stitchArrays} from '#sugar';
 
 export default {
-  contentDependencies: ['linkTrack', 'linkContribution'],
+  contentDependencies: ['generateArtistCredit', 'linkTrack'],
 
   extraDependencies: ['html', 'language'],
 
@@ -10,11 +10,10 @@ export default {
       tracks
         .map(track => relation('linkTrack', track)),
 
-    contributionLinks:
+    artistCredits:
       tracks
         .map(track =>
-          track.artistContribs
-            .map(contrib => relation('linkContribution', contrib))),
+          relation('generateArtistCredit', track.artistContribs, [])),
   }),
 
   generate: (relations, {html, language}) =>
@@ -23,22 +22,32 @@ export default {
 
       stitchArrays({
         trackLink: relations.trackLinks,
-        contributionLinks: relations.contributionLinks,
-      }).map(({trackLink, contributionLinks}) =>
+        artistCredit: relations.artistCredits,
+      }).map(({trackLink, artistCredit}) =>
           html.tag('li',
             language.encapsulate('trackList.item', itemCapsule =>
               language.encapsulate(itemCapsule, workingCapsule => {
                 const workingOptions = {track: trackLink};
 
-                if (!empty(contributionLinks)) {
+                const artistCapsule = language.encapsulate(itemCapsule, 'withArtists');
+
+                artistCredit.setSlots({
+                  normalStringKey:
+                    artistCapsule + '.by',
+
+                  featuringStringKey:
+                    artistCapsule + '.featuring',
+
+                  normalFeaturingStringKey:
+                    artistCapsule + '.by.featuring',
+                });
+
+                if (!html.isBlank(artistCredit)) {
                   workingCapsule += '.withArtists';
                   workingOptions.by =
                     html.tag('span', {class: 'by'},
                       html.metatag('chunkwrap', {split: ','},
-                        language.$(itemCapsule, 'withArtists.by', {
-                          artists:
-                            language.formatConjunctionList(contributionLinks),
-                        })));
+                        html.resolve(artistCredit)));
                 }
 
                 return language.$(workingCapsule, workingOptions);