« 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/generateCoverArtworkOriginDetails.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateCoverArtworkOriginDetails.js')
-rw-r--r--src/content/dependencies/generateCoverArtworkOriginDetails.js66
1 files changed, 37 insertions, 29 deletions
diff --git a/src/content/dependencies/generateCoverArtworkOriginDetails.js b/src/content/dependencies/generateCoverArtworkOriginDetails.js
index c0109141..6cb529b1 100644
--- a/src/content/dependencies/generateCoverArtworkOriginDetails.js
+++ b/src/content/dependencies/generateCoverArtworkOriginDetails.js
@@ -3,6 +3,7 @@ import Thing from '#thing';
 export default {
   contentDependencies: [
     'generateArtistCredit',
+    'generateAbsoluteDatetimestamp',
     'linkAlbum',
     'transformContent',
   ],
@@ -25,17 +26,18 @@ export default {
       (query.artworkThingType === 'album'
         ? relation('linkAlbum', artwork.thing)
         : null),
+
+    datetimestamp:
+      (artwork.date !== artwork.thing.date
+        ? relation('generateAbsoluteDatetimestamp', artwork.date)
+        : null),
   }),
 
+
   data: (query, artwork) => ({
     label:
       artwork.label,
 
-    date:
-      (artwork.date !== artwork.thing.date
-        ? artwork.date
-        : null),
-
     artworkThingType:
       query.artworkThingType,
   }),
@@ -49,25 +51,36 @@ export default {
         {class: 'origin-details'},
 
         [
-          relations.credit.slots({
-            showAnnotation: true,
-            showExternalLinks: true,
-            showChronology: true,
-            showWikiEdits: true,
-
-            trimAnnotation: false,
-
-            chronologyKind: 'coverArt',
-
-            normalStringKey:
-              (data.label
-                ? capsule + '.artworkBy.customLabel'
-                : capsule + '.artworkBy'),
-
-            additionalStringOptions:
-              (data.label
-                ? {label: data.label}
-                : {}),
+          language.encapsulate(capsule, 'artworkBy', workingCapsule => {
+            const workingOptions = {};
+
+            if (data.label) {
+              workingCapsule += '.customLabel';
+              workingOptions.label = data.label;
+            }
+
+            if (relations.datetimestamp) {
+              workingCapsule += '.withYear';
+              workingOptions.year =
+                relations.datetimestamp.slots({
+                  style: 'year',
+                  tooltip: true,
+                });
+            }
+
+            return relations.credit.slots({
+              showAnnotation: true,
+              showExternalLinks: true,
+              showChronology: true,
+              showWikiEdits: true,
+
+              trimAnnotation: false,
+
+              chronologyKind: 'coverArt',
+
+              normalStringKey: workingCapsule,
+              additionalStringOptions: workingOptions,
+            });
           }),
 
           pagePath[0] === 'track' &&
@@ -77,11 +90,6 @@ export default {
                 relations.albumLink.slot('color', false),
             }),
 
-          language.$(capsule, 'released', {
-            [language.onlyIfOptions]: ['date'],
-            date: language.formatDate(data.date),
-          }),
-
           language.$(capsule, 'source', {
             [language.onlyIfOptions]: ['source'],
             source: relations.source.slot('mode', 'inline'),