From 89e79008b02331b69660bb16b6ca737e37483e61 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 23 Jun 2023 19:41:15 -0300 Subject: content: generateCoverCarousel This also introduces a handy stitchArrays() utility, which probably has some uses not caught in this commit. --- src/content/dependencies/generateCoverGrid.js | 45 ++++++++++++++------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'src/content/dependencies/generateCoverGrid.js') 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), + ], + })))); }, }; -- cgit 1.3.0-6-gf8a5