« get me outta code hell

content: generateCommentaryEntry: add color slot - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateCommentaryEntry.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-16 14:25:37 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-16 14:25:37 -0400
commit7a5b4465069d594a90c8e783e646a3248408ddaf (patch)
tree12af8a1641b99eaaf1877b2555a511d8102dad65 /src/content/dependencies/generateCommentaryEntry.js
parent233e46c8d9099b4f6d2174e12f2b287478c54f40 (diff)
content: generateCommentaryEntry: add color slot
Diffstat (limited to 'src/content/dependencies/generateCommentaryEntry.js')
-rw-r--r--src/content/dependencies/generateCommentaryEntry.js27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/content/dependencies/generateCommentaryEntry.js b/src/content/dependencies/generateCommentaryEntry.js
index 22e8fd1e..72e30657 100644
--- a/src/content/dependencies/generateCommentaryEntry.js
+++ b/src/content/dependencies/generateCommentaryEntry.js
@@ -1,5 +1,10 @@
 export default {
-  contentDependencies: ['linkArtist', 'transformContent'],
+  contentDependencies: [
+    'generateColorStyleVariables',
+    'linkArtist',
+    'transformContent',
+  ],
+
   extraDependencies: ['html', 'language'],
 
   relations: (relation, entry) => ({
@@ -22,13 +27,20 @@ export default {
       (entry.body
         ? relation('transformContent', entry.body)
         : null),
+
+    colorVariables:
+      relation('generateColorStyleVariables'),
   }),
 
   data: (entry) => ({
     date: entry.date,
   }),
 
-  generate(data, relations, {html, language}) {
+  slots: {
+    color: {validate: v => v.isColor},
+  },
+
+  generate(data, relations, slots, {html, language}) {
     const artistsSpan =
       html.tag('span', {class: 'commentary-entry-artists'},
         (relations.artistsContent
@@ -66,11 +78,18 @@ export default {
       titleOptions.accent = accent;
     }
 
+    const style =
+      (slots.color
+        ? relations.colorVariables
+            .slot('color', slots.color)
+            .content
+        : null);
+
     return html.tags([
-      html.tag('p', {class: 'commentary-entry-heading'},
+      html.tag('p', {class: 'commentary-entry-heading', style},
         language.$(...titleParts, titleOptions)),
 
-      html.tag('blockquote', {class: 'commentary-entry-body'},
+      html.tag('blockquote', {class: 'commentary-entry-body', style},
         relations.bodyContent.slot('mode', 'multiline')),
     ]);
   },