« get me outta code hell

content: generate{Album,Track}CoverArtwork: content warnings(!!) - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-12-09 16:06:49 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-12-09 16:06:49 -0400
commit8d3f6d3895c2cafe902a781f11e7a9d989edbf07 (patch)
tree47a80d8482e3414bded9e4145160f4366886f40b /src/content/dependencies
parenta38dc428670ffa520b804f675ded9d11d468f15e (diff)
content: generate{Album,Track}CoverArtwork: content warnings(!!)
oops :+1:
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateAlbumCoverArtwork.js6
-rw-r--r--src/content/dependencies/generateTrackCoverArtwork.js30
2 files changed, 28 insertions, 8 deletions
diff --git a/src/content/dependencies/generateAlbumCoverArtwork.js b/src/content/dependencies/generateAlbumCoverArtwork.js
index 1e11c0ac..ff7d2b85 100644
--- a/src/content/dependencies/generateAlbumCoverArtwork.js
+++ b/src/content/dependencies/generateAlbumCoverArtwork.js
@@ -45,6 +45,11 @@ export default {
 
     dimensions:
       album.coverArtDimensions,
+
+    warnings:
+      album.artTags
+        .filter(tag => tag.isContentWarning)
+        .map(tag => tag.name),
   }),
 
   slots: {
@@ -73,6 +78,7 @@ export default {
         }),
 
       dimensions: data.dimensions,
+      warnings: data.warnings,
 
       details: [
         slots.details === 'tags' &&
diff --git a/src/content/dependencies/generateTrackCoverArtwork.js b/src/content/dependencies/generateTrackCoverArtwork.js
index 90ce2b4a..9153e2fc 100644
--- a/src/content/dependencies/generateTrackCoverArtwork.js
+++ b/src/content/dependencies/generateTrackCoverArtwork.js
@@ -12,7 +12,19 @@ export default {
 
   extraDependencies: ['html', 'language'],
 
-  relations: (relation, track) => ({
+  query: (track) => ({
+    artTags:
+      (track.hasUniqueCoverArt
+        ? track.artTags
+        : track.album.artTags),
+
+    coverArtistContribs:
+      (track.hasUniqueCoverArt
+        ? track.coverArtistContribs
+        : track.album.coverArtistContribs),
+  }),
+
+  relations: (relation, query, track) => ({
     coverArtwork:
       relation('generateCoverArtwork'),
 
@@ -21,15 +33,11 @@ export default {
 
     artTagDetails:
       relation('generateCoverArtworkArtTagDetails',
-        (track.hasUniqueCoverArt
-          ? track.artTags
-          : track.album.artTags)),
+        query.artTags),
 
     artistDetails:
       relation('generateCoverArtworkArtistDetails',
-        (track.hasUniqueCoverArt
-          ? track.coverArtistContribs
-          : track.album.coverArtistContribs)),
+        query.coverArtistContribs),
 
     referenceDetails:
       relation('generateCoverArtworkReferenceDetails',
@@ -46,7 +54,7 @@ export default {
       relation('linkAlbum', track.album),
   }),
 
-  data: (track) => ({
+  data: (query, track) => ({
     path:
       (track.hasUniqueCoverArt
         ? ['media.trackCover', track.album.directory, track.directory, track.coverArtFileExtension]
@@ -62,6 +70,11 @@ export default {
 
     nonUnique:
       !track.hasUniqueCoverArt,
+
+    warnings:
+      query.artTags
+        .filter(tag => tag.isContentWarning)
+        .map(tag => tag.name),
   }),
 
   slots: {
@@ -95,6 +108,7 @@ export default {
         }),
 
       dimensions: data.dimensions,
+      warnings: data.warnings,
 
       details: [
         slots.details === 'tags' &&