« get me outta code hell

content, client: memorable details, collapsed crediting/ref sources - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateContentContentHeading.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-10-06 15:23:25 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-10-06 15:23:25 -0300
commit6a99486d361b1fb8af6be08cb9c1adbbcd0b0e8f (patch)
tree21e457e2a3b168c6e257c8f5209aef3be89ad508 /src/content/dependencies/generateContentContentHeading.js
parentf820d83e94cf014e34857c69598261680c72329c (diff)
content, client: memorable details, collapsed crediting/ref sources preview
Diffstat (limited to 'src/content/dependencies/generateContentContentHeading.js')
-rw-r--r--src/content/dependencies/generateContentContentHeading.js51
1 files changed, 43 insertions, 8 deletions
diff --git a/src/content/dependencies/generateContentContentHeading.js b/src/content/dependencies/generateContentContentHeading.js
index 555abb6b..54ffa205 100644
--- a/src/content/dependencies/generateContentContentHeading.js
+++ b/src/content/dependencies/generateContentContentHeading.js
@@ -9,7 +9,9 @@ export default {
 
   data: (thing) => ({
     name:
-      thing.name,
+      (thing
+        ? thing.name
+        : null),
   }),
 
   slots: {
@@ -21,6 +23,11 @@ export default {
     string: {
       type: 'string',
     },
+
+    summary: {
+      type: 'boolean',
+      default: false,
+    },
   },
 
   generate: (data, relations, slots, {html, language}) =>
@@ -28,14 +35,42 @@ export default {
       attributes: slots.attributes,
 
       title:
-        slots.string &&
-        language.$(slots.string, {
-          thing:
-            html.tag('i', data.name),
-        }),
+        (() => {
+          if (!slots.string) return html.blank();
+
+          const options = {};
+
+          if (slots.summary) {
+            options.cue =
+              html.tag('span', {class: 'cue'},
+                language.$(slots.string, 'cue'));
+          }
+
+          if (data.name) {
+            options.thing = html.tag('i', data.name);
+          }
+
+          if (slots.summary) {
+            return html.tags([
+              html.tag('span', {class: 'when-open'},
+                language.$(slots.string, options)),
+
+              html.tag('span', {class: 'when-collapsed'},
+                language.$(slots.string, 'collapsed', options)),
+            ]);
+          } else {
+            return language.$(slots.string, options);
+          }
+        })(),
 
       stickyTitle:
-        slots.string &&
-        language.$(slots.string, 'sticky'),
+        (slots.string
+          ? language.$(slots.string, 'sticky')
+          : html.blank()),
+
+      tag:
+        (slots.summary
+          ? 'summary'
+          : 'p'),
     }),
 };