« 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/generateAdditionalFilesListChunk.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateAdditionalFilesListChunk.js')
-rw-r--r--src/content/dependencies/generateAdditionalFilesListChunk.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/content/dependencies/generateAdditionalFilesListChunk.js b/src/content/dependencies/generateAdditionalFilesListChunk.js
new file mode 100644
index 0000000..bb16b77
--- /dev/null
+++ b/src/content/dependencies/generateAdditionalFilesListChunk.js
@@ -0,0 +1,39 @@
+export default {
+  extraDependencies: ['html', 'language'],
+
+  slots: {
+    title: {
+      type: 'html',
+      mutable: false,
+    },
+
+    description: {
+      type: 'html',
+      mutable: false,
+    },
+
+    items: {
+      validate: v => v.looseArrayOf(v.isHTML),
+    },
+  },
+
+  generate(slots, {html, language}) {
+    const titleParts = ['releaseInfo.additionalFiles.entry'];
+    const titleOptions = {title: slots.title};
+
+    if (!html.isBlank(slots.description)) {
+      titleParts.push('withDescription');
+      titleOptions.description = slots.description;
+    }
+
+    const dt =
+      html.tag('dt',
+        language.$(...titleParts, titleOptions));
+
+    const dd =
+      html.tag('dd',
+        html.tag('ul', slots.items));
+
+    return html.tags([dt, dd]);
+  },
+};