« get me outta code hell

content, css: cover artwork reference details, non-unique art line - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateCoverArtworkReferenceDetails.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-11-19 15:56:40 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-11-19 16:05:41 -0400
commitc31d38c4778e51fb90958c40af93519661538889 (patch)
treec9d7b42e9a26657efebb22495424c26b19848a5e /src/content/dependencies/generateCoverArtworkReferenceDetails.js
parentd746ff26c3e7517c8aaff7615ae4da06fa2d01c0 (diff)
content, css: cover artwork reference details, non-unique art line
Diffstat (limited to 'src/content/dependencies/generateCoverArtworkReferenceDetails.js')
-rw-r--r--src/content/dependencies/generateCoverArtworkReferenceDetails.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/content/dependencies/generateCoverArtworkReferenceDetails.js b/src/content/dependencies/generateCoverArtworkReferenceDetails.js
new file mode 100644
index 00000000..006b2b4b
--- /dev/null
+++ b/src/content/dependencies/generateCoverArtworkReferenceDetails.js
@@ -0,0 +1,56 @@
+export default {
+  extraDependencies: ['html', 'language'],
+
+  data: (referenced, referencedBy) => ({
+    referenced:
+      referenced.length,
+
+    referencedBy:
+      referencedBy.length,
+  }),
+
+  slots: {
+    referencedLink: {type: 'html', mutable: true},
+    referencingLink: {type: 'html', mutable: true},
+  },
+
+  generate: (data, slots, {html, language}) =>
+    language.encapsulate('releaseInfo', capsule => {
+      const referencedText =
+        language.$(capsule, 'referencesArtworks', {
+          [language.onlyIfOptions]: ['artworks'],
+
+          artworks:
+            language.countArtworks(data.referenced, {
+              blankIfZero: true,
+              unit: true,
+            }),
+        });
+
+      const referencingText =
+        language.$(capsule, 'referencedByArtworks', {
+          [language.onlyIfOptions]: ['artworks'],
+
+          artworks:
+            language.countArtworks(data.referencedBy, {
+              blankIfZero: true,
+              unit: true,
+            }),
+        });
+
+      return (
+        html.tag('p', {class: 'image-details'},
+          {[html.onlyIfContent]: true},
+          {[html.joinChildren]: html.tag('br')},
+
+          {class: 'reference-details'},
+
+          [
+            !html.isBlank(referencedText) &&
+              slots.referencedLink.slot('content', referencedText),
+
+            !html.isBlank(referencingText) &&
+              slots.referencingLink.slot('content', referencingText),
+          ]));
+    }),
+}