From bdb4276ffae1c978ec1d1a6e462faf8c117e20a9 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 26 Jul 2023 11:13:29 -0300 Subject: content: generateGridActionLinks --- src/content/dependencies/generateCoverCarousel.js | 67 ++++++++++++++--------- 1 file changed, 40 insertions(+), 27 deletions(-) (limited to 'src/content/dependencies/generateCoverCarousel.js') diff --git a/src/content/dependencies/generateCoverCarousel.js b/src/content/dependencies/generateCoverCarousel.js index e854113e..c3ce1df6 100644 --- a/src/content/dependencies/generateCoverCarousel.js +++ b/src/content/dependencies/generateCoverCarousel.js @@ -2,16 +2,24 @@ import {empty, repeat, stitchArrays} from '../../util/sugar.js'; import {getCarouselLayoutForNumberOfItems} from '../../util/wiki-data.js'; export default { + contentDependencies: ['generateGridActionLinks'], extraDependencies: ['html'], + relations(relation) { + return { + actionLinks: relation('generateGridActionLinks'), + }; + }, + slots: { images: {validate: v => v.strictArrayOf(v.isHTML)}, links: {validate: v => v.strictArrayOf(v.isHTML)}, lazy: {validate: v => v.oneOf(v.isWholeNumber, v.isBoolean)}, + actionLinks: {validate: v => v.sparseArrayOf(v.isHTML)}, }, - generate(slots, {html}) { + generate(relations, slots, {html}) { const stitched = stitchArrays({ image: slots.images, @@ -24,31 +32,36 @@ export default { const layout = getCarouselLayoutForNumberOfItems(stitched.length); - return html.tag('div', - { - class: 'carousel-container', - 'data-carousel-rows': layout.rows, - 'data-carousel-columns': layout.columns, - }, - repeat(3, [ - html.tag('div', - {class: 'carousel-grid', 'aria-hidden': 'true'}, - stitched.map(({image, link}, index) => - html.tag('div', {class: 'carousel-item'}, - link.slots({ - attributes: {tabindex: '-1'}, - content: - image.slots({ - thumb: 'small', - square: true, - lazy: - (typeof slots.lazy === 'number' - ? index >= slots.lazy - : typeof slots.lazy === 'boolean' - ? slots.lazy - : false), - }), - })))), - ])); + return html.tags([ + html.tag('div', + { + class: 'carousel-container', + 'data-carousel-rows': layout.rows, + 'data-carousel-columns': layout.columns, + }, + repeat(3, [ + html.tag('div', + {class: 'carousel-grid', 'aria-hidden': 'true'}, + stitched.map(({image, link}, index) => + html.tag('div', {class: 'carousel-item'}, + link.slots({ + attributes: {tabindex: '-1'}, + content: + image.slots({ + thumb: 'small', + square: true, + lazy: + (typeof slots.lazy === 'number' + ? index >= slots.lazy + : typeof slots.lazy === 'boolean' + ? slots.lazy + : false), + }), + })))), + ])), + + relations.actionLinks + .slot('actionLinks', slots.actionLinks), + ]); }, }; -- cgit 1.3.0-6-gf8a5