« 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/generatePageBanner.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generatePageBanner.js')
-rw-r--r--src/content/dependencies/generatePageBanner.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/content/dependencies/generatePageBanner.js b/src/content/dependencies/generatePageBanner.js
new file mode 100644
index 00000000..835140a8
--- /dev/null
+++ b/src/content/dependencies/generatePageBanner.js
@@ -0,0 +1,28 @@
+export default {
+  extraDependencies: ['html', 'to'],
+
+  slots: {
+    path: {
+      validate: v => v.validateArrayItems(v.isString),
+    },
+
+    dimensions: {
+      validate: v => v.isDimensions,
+    },
+
+    alt: {
+      type: 'string',
+    },
+  },
+
+  generate(slots, {html, to}) {
+    return (
+      html.tag('div', {id: 'banner'},
+        html.tag('img', {
+          src: to(...slots.path),
+          alt: slots.alt,
+          width: slots.dimensions?.[0] ?? 1100,
+          height: slots.dimensions?.[1] ?? 200,
+        })));
+  },
+};