diff options
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 |
commit | f4dea3cb8d4a0dfdbe3f8c107dbf253dec5b99ea (patch) | |
tree | c95d86cb8be005e35f97fb7b888e71847790483f | |
parent | 3e9d8dd7f526f7f885c9372c35b8402397f52f3f (diff) |
content: generateBanner: refactor attributes, fix undefined alt
-rw-r--r-- | src/content/dependencies/generateBanner.js | 25 |
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})), }; |