« get me outta code hell

content: generateBanner: refactor attributes, fix undefined alt - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-12-31 23:25:12 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-31 23:28:54 -0400
commitf4dea3cb8d4a0dfdbe3f8c107dbf253dec5b99ea (patch)
treec95d86cb8be005e35f97fb7b888e71847790483f /src/content
parent3e9d8dd7f526f7f885c9372c35b8402397f52f3f (diff)
content: generateBanner: refactor attributes, fix undefined alt
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateBanner.js25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/content/dependencies/generateBanner.js b/src/content/dependencies/generateBanner.js
index 835140a8..15eb08eb 100644
--- a/src/content/dependencies/generateBanner.js
+++ b/src/content/dependencies/generateBanner.js
@@ -15,14 +15,19 @@ export default {
     },
   },
 
-  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,
-        })));
-  },
+  generate: (slots, {html, to}) =>
+    html.tag('div', {id: 'banner'},
+      html.tag('img',
+        {src: to(...slots.path)},
+
+        (slots.dimensions
+          ? {width: slots.dimensions[0]}
+          : {width: 1100}),
+
+        (slots.dimensions
+          ? {height: slots.dimensions[1]}
+          : {height: 200}),
+
+        slots.alt &&
+          {alt: slots.alt})),
 };