« get me outta code hell

content, data: generateRelationsContentHeading, Track.nameStyle - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateRelationsContentHeading.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-05-11 19:00:59 -0300
committer(quasar) nebula <qznebula@protonmail.com>2026-05-11 19:00:59 -0300
commit657e1c1e447ad8939d2ad9286af00be52975f791 (patch)
tree8f471ff45bad3f1890357f8cbe54c75e5b01fb09 /src/content/dependencies/generateRelationsContentHeading.js
parent38672451c0f2380093283156609018cce789bb50 (diff)
content, data: generateRelationsContentHeading, Track.nameStyle
Diffstat (limited to 'src/content/dependencies/generateRelationsContentHeading.js')
-rw-r--r--src/content/dependencies/generateRelationsContentHeading.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/content/dependencies/generateRelationsContentHeading.js b/src/content/dependencies/generateRelationsContentHeading.js
new file mode 100644
index 00000000..5d50c2fc
--- /dev/null
+++ b/src/content/dependencies/generateRelationsContentHeading.js
@@ -0,0 +1,39 @@
+export default {
+  relations: (relation, _thing) => ({
+    contentHeading:
+      relation('generateContentHeading'),
+  }),
+
+  data: (nameSlot, thing) => ({
+    nameSlot,
+
+    name: thing.name,
+    nameStyle: thing.nameStyle,
+  }),
+
+  slots: {
+    attributes: {type: 'attributes', mutable: false},
+    string: {type: 'string'},
+  },
+
+  generate(data, relations, slots, {html, language}) {
+    const namePart =
+      (data.nameStyle === 'utility'
+        ? null
+        : html.tag('i', data.name));
+
+    const title =
+      (namePart
+        ? language.$(slots.string, {[data.nameSlot]: namePart})
+        : language.$(slots.string, 'withoutName'));
+
+    const stickyTitle =
+      language.$(slots.string, 'sticky');
+
+    return relations.contentHeading.slots({
+      attributes: slots.attributes,
+      title,
+      stickyTitle,
+    });
+  },
+};