« get me outta code hell

content, css: generateCoverArtwork: 'primary-artists' mode - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateCoverArtwork.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-11-17 15:55:28 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-11-17 16:35:31 -0400
commitc656395edea65e6eead8e3cbe1a9ecb067ad5ef6 (patch)
tree28642821ef167c2ac301b72cf85bbaefdcf7bde2 /src/content/dependencies/generateCoverArtwork.js
parentd3a0e1b52aef93e3f74e557229e93a0a123c3e4b (diff)
content, css: generateCoverArtwork: 'primary-artists' mode
Diffstat (limited to 'src/content/dependencies/generateCoverArtwork.js')
-rw-r--r--src/content/dependencies/generateCoverArtwork.js57
1 files changed, 47 insertions, 10 deletions
diff --git a/src/content/dependencies/generateCoverArtwork.js b/src/content/dependencies/generateCoverArtwork.js
index 3d5a614f..70d71bc6 100644
--- a/src/content/dependencies/generateCoverArtwork.js
+++ b/src/content/dependencies/generateCoverArtwork.js
@@ -1,27 +1,32 @@
 import {stitchArrays} from '#sugar';
 
 export default {
-  contentDependencies: ['image', 'linkArtTag'],
-  extraDependencies: ['html'],
+  contentDependencies: ['image', 'linkArtTag', 'linkArtistGallery'],
+  extraDependencies: ['html', 'language'],
 
-  query: (artTags) => ({
+  query: (artTags, _coverArtistContribs) => ({
     linkableArtTags:
       (artTags
         ? artTags.filter(tag => !tag.isContentWarning)
         : []),
   }),
 
-  relations: (relation, query, artTags) => ({
+  relations: (relation, query, artTags, coverArtistContribs) => ({
     image:
       relation('image', artTags),
 
     tagLinks:
       query.linkableArtTags
-        .filter(tag => !tag.isContentWarning)
         .map(tag => relation('linkArtTag', tag)),
+
+    artistLinks:
+      coverArtistContribs
+        .map(contrib => contrib.artist)
+        .map(artist =>
+          relation('linkArtistGallery', artist)),
   }),
 
-  data: (query) => {
+  data: (query, _artTags, _coverArtistContribs) => {
     const data = {};
 
     const seenShortNames = new Set();
@@ -56,8 +61,15 @@ export default {
     },
 
     mode: {
-      validate: v => v.is('primary', 'thumbnail', 'commentary'),
-      default: 'primary',
+      validate: v =>
+        v.is(...[
+          'primary-tags',
+          'primary-artists',
+          'thumbnail',
+          'commentary',
+        ]),
+
+      default: 'primary-tags',
     },
 
     dimensions: {
@@ -65,7 +77,7 @@ export default {
     },
   },
 
-  generate(data, relations, slots, {html}) {
+  generate(data, relations, slots, {html, language}) {
     const square =
       (slots.dimensions
         ? slots.dimensions[0] === slots.dimensions[1]
@@ -77,7 +89,7 @@ export default {
         : {dimensions: slots.dimensions});
 
     switch (slots.mode) {
-      case 'primary':
+      case 'primary-tags':
         return html.tags([
           relations.image.slots({
             path: slots.path,
@@ -92,6 +104,8 @@ export default {
           html.tag('ul', {class: 'image-details'},
             {[html.onlyIfContent]: true},
 
+            {class: 'art-tag-details'},
+
             stitchArrays({
               tagLink: relations.tagLinks,
               preferShortName: data.preferShortName,
@@ -100,6 +114,29 @@ export default {
                   tagLink.slot('preferShortName', preferShortName)))),
         ]);
 
+      case 'primary-artists':
+        return html.tags([
+          relations.image.slots({
+            path: slots.path,
+            alt: slots.alt,
+            color: slots.color,
+            thumb: 'medium',
+            reveal: true,
+            link: true,
+            ...sizeSlots,
+          }),
+
+          html.tag('p', {class: 'image-details'},
+            {[html.onlyIfContent]: true},
+
+            {class: 'illustrator-details'},
+
+            language.$('misc.coverGrid.details.coverArtists', {
+              artists:
+                language.formatConjunctionList(relations.artistLinks),
+            })),
+        ]);
+
       case 'thumbnail':
         return relations.image.slots({
           path: slots.path,