« get me outta code hell

content, data: generateArtistInfoPageMusicVideosChunkedList - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateArtistInfoPageMusicVideosChunkItem.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-04-14 20:26:02 -0300
committer(quasar) nebula <qznebula@protonmail.com>2026-04-14 20:26:02 -0300
commit2336e252d25536d3678119ff070189e666b98927 (patch)
tree788b9c689b8c7ac4324af092c73e95f20b5abd6f /src/content/dependencies/generateArtistInfoPageMusicVideosChunkItem.js
parented38f9529084cdd3ff6cdfb56148fd9a99c259b2 (diff)
content, data: generateArtistInfoPageMusicVideosChunkedList
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageMusicVideosChunkItem.js')
-rw-r--r--src/content/dependencies/generateArtistInfoPageMusicVideosChunkItem.js118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageMusicVideosChunkItem.js b/src/content/dependencies/generateArtistInfoPageMusicVideosChunkItem.js
new file mode 100644
index 00000000..8bae860d
--- /dev/null
+++ b/src/content/dependencies/generateArtistInfoPageMusicVideosChunkItem.js
@@ -0,0 +1,118 @@
+import {empty} from '#sugar';
+import {selectRepresentativeArtistContributorContribs} from '#wiki-data';
+
+export default {
+  query(_artist, contribs) {
+    const query = {};
+
+    query.musicVideo = contribs[0].thing;
+
+    query.albumOrTrack = query.musicVideo.thing;
+
+    query.album =
+      (query.albumOrTrack.isAlbum
+        ? query.albumOrTrack
+        : query.albumOrTrack.album);
+
+    query.displayedContributions =
+      selectRepresentativeArtistContributorContribs(contribs);
+
+    return query;
+  },
+
+  relations: (relation, query, artist, _contribs) => ({
+    template:
+      relation('generateArtistInfoPageChunkItem'),
+
+    trackLink:
+      (query.albumOrTrack.isTrack
+        ? relation('linkTrack', query.albumOrTrack)
+        : null),
+
+    artistCredit:
+      relation('generateArtistCredit',
+        query.musicVideo.artistContribs,
+        (empty(query.album.artistContribs)
+          ? [artist.mockSimpleContribution]
+          : query.album.artistContribs)),
+
+    externalLinks:
+      query.musicVideo.urls
+        .map(url => relation('linkExternal', url)),
+  }),
+
+  data: (query, _artist, contribs) => ({
+    date: contribs[0].date,
+
+    for:
+      (query.albumOrTrack.isAlbum
+        ? 'album'
+        : 'track'),
+
+    title: query.musicVideo.title,
+    label: query.musicVideo.label,
+
+    contribAnnotationParts:
+      (query.displayedContributions
+        ? query.displayedContributions
+            .flatMap(contrib => contrib.annotationParts)
+        : null),
+  }),
+
+  generate: (data, relations, {html, language}) =>
+    relations.template.slots({
+      annotation:
+        (data.contribAnnotationParts
+          ? language.formatUnitList(data.contribAnnotationParts)
+          : html.blank()),
+
+      content:
+        language.encapsulate('artistPage.creditList.entry', entryCapsule => {
+          let workingCapsule = entryCapsule;
+          let workingOptions = {};
+
+          workingCapsule += '.' + data.for + '.musicVideo';
+
+          const musicVideoCapsule = workingCapsule;
+
+          if (data.for === 'track') {
+            workingOptions.track =
+              relations.trackLink;
+          }
+
+          if (data.date) {
+            workingCapsule += '.withDate';
+            workingOptions.date = language.formatDate(data.date);
+          }
+
+          relations.artistCredit.setSlots({
+            normalStringKey:
+              musicVideoCapsule + '.credit' +
+                (data.title ? '.alongsideTitle'
+               : data.label ? '.alongsideLabel'
+                            : ''),
+          });
+
+          if (!html.isBlank(relations.artistCredit)) {
+            workingCapsule += '.withCredit';
+            workingOptions.credit = relations.artistCredit;
+          }
+
+          if (data.title) {
+            workingCapsule += '.withTitle';
+            workingOptions.title = language.sanitize(data.title);
+          } else if (data.label) {
+            workingCapsule += '.withLabel';
+            workingOptions.label = language.sanitize(data.label);
+          }
+
+          if (!empty(relations.externalLinks)) {
+            workingCapsule += '.withLinks';
+            workingOptions.links =
+              language.formatUnitList(relations.externalLinks);
+          }
+
+          return language.$(workingCapsule, workingOptions);
+        }),
+    }),
+};