diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-06-23 19:41:15 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-06-23 19:41:38 -0300 |
commit | 89e79008b02331b69660bb16b6ca737e37483e61 (patch) | |
tree | 90d24e41e72f72bb3e9898d52c19aad323456bdd /src/content/dependencies/generateCoverGrid.js | |
parent | d7bd80239dead1179450b2a0b97f97c59e150905 (diff) |
content: generateCoverCarousel
This also introduces a handy stitchArrays() utility, which probably has some uses not caught in this commit.
Diffstat (limited to 'src/content/dependencies/generateCoverGrid.js')
-rw-r--r-- | src/content/dependencies/generateCoverGrid.js | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/content/dependencies/generateCoverGrid.js b/src/content/dependencies/generateCoverGrid.js index a024ae25..970aa05c 100644 --- a/src/content/dependencies/generateCoverGrid.js +++ b/src/content/dependencies/generateCoverGrid.js @@ -1,3 +1,5 @@ +import {stitchArrays} from '../../util/sugar.js'; + export default { extraDependencies: ['html'], @@ -12,27 +14,26 @@ export default { generate(slots, {html}) { return ( html.tag('div', {class: 'grid-listing'}, - slots.images.map((image, i) => { - const link = slots.links[i]; - const name = slots.names[i]; - return link.slots({ - content: [ - image.slots({ - thumb: 'medium', - lazy: - (typeof slots.lazy === 'number' - ? i >= slots.lazy - : typeof slots.lazy === 'boolean' - ? slots.lazy - : false), - square: true, - }), - html.tag('span', name), - ], - attributes: { - class: ['grid-item', 'box', /* large && 'large-grid-item' */], - }, - }); - }))); + stitchArrays({ + image: slots.images, + link: slots.links, + name: slots.names, + }).map(({image, link, name}, index) => + link.slots({ + attributes: {class: ['grid-item', 'box']}, + content: [ + image.slots({ + thumb: 'medium', + square: true, + lazy: + (typeof slots.lazy === 'number' + ? index >= slots.lazy + : typeof slots.lazy === 'boolean' + ? slots.lazy + : false), + }), + html.tag('span', name), + ], + })))); }, }; |