« 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/generateAlbumCoverArtwork.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateAlbumCoverArtwork.js')
-rw-r--r--src/content/dependencies/generateAlbumCoverArtwork.js41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/content/dependencies/generateAlbumCoverArtwork.js b/src/content/dependencies/generateAlbumCoverArtwork.js
index d52d57ce..1e11c0ac 100644
--- a/src/content/dependencies/generateAlbumCoverArtwork.js
+++ b/src/content/dependencies/generateAlbumCoverArtwork.js
@@ -3,7 +3,10 @@ export default {
     'generateCoverArtwork',
     'generateCoverArtworkArtTagDetails',
     'generateCoverArtworkArtistDetails',
+    'generateCoverArtworkReferenceDetails',
     'image',
+    'linkAlbumReferencedArtworks',
+    'linkAlbumReferencingArtworks',
   ],
 
   extraDependencies: ['html', 'language'],
@@ -20,6 +23,17 @@ export default {
 
     artistDetails:
       relation('generateCoverArtworkArtistDetails', album.coverArtistContribs),
+
+    referenceDetails:
+      relation('generateCoverArtworkReferenceDetails',
+        album.referencedArtworks,
+        album.referencedByArtworks),
+
+    referencedArtworksLink:
+      relation('linkAlbumReferencedArtworks', album),
+
+    referencingArtworksLink:
+      relation('linkAlbumReferencingArtworks', album),
   }),
 
   data: (album) => ({
@@ -40,6 +54,11 @@ export default {
       validate: v => v.is('tags', 'artists'),
       default: 'tags',
     },
+
+    showReferenceLinks: {
+      type: 'boolean',
+      default: false,
+    },
   },
 
   generate: (data, relations, slots, {language}) =>
@@ -55,11 +74,21 @@ export default {
 
       dimensions: data.dimensions,
 
-      details:
-        (slots.details === 'tags'
-          ? relations.artTagDetails
-       : slots.details === 'artists'
-          ? relations.artistDetails
-          : null),
+      details: [
+        slots.details === 'tags' &&
+          relations.artTagDetails,
+
+        slots.details === 'artists' &&
+          relations.artistDetails,
+
+        slots.showReferenceLinks &&
+          relations.referenceDetails.slots({
+            referencedLink:
+              relations.referencedArtworksLink,
+
+            referencingLink:
+              relations.referencingArtworksLink,
+          }),
+      ],
     }),
 };