From 535acb34613b5cf7e22654619f4337b94b70644d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 12 Jun 2023 16:35:38 -0300 Subject: content: cut html.template boilerplate --- src/content/dependencies/generateCoverGrid.js | 68 ++++++++++++--------------- 1 file changed, 31 insertions(+), 37 deletions(-) (limited to 'src/content/dependencies/generateCoverGrid.js') diff --git a/src/content/dependencies/generateCoverGrid.js b/src/content/dependencies/generateCoverGrid.js index fdd9f8b7..a024ae25 100644 --- a/src/content/dependencies/generateCoverGrid.js +++ b/src/content/dependencies/generateCoverGrid.js @@ -1,44 +1,38 @@ export default { extraDependencies: ['html'], - generate({html}) { - return html.template({ - annotation: `generateCoverGrid`, + slots: { + images: {validate: v => v.arrayOf(v.isHTML)}, + links: {validate: v => v.arrayOf(v.isHTML)}, + names: {validate: v => v.arrayOf(v.isString)}, - slots: { - images: {validate: v => v.arrayOf(v.isHTML)}, - links: {validate: v => v.arrayOf(v.isHTML)}, - names: {validate: v => v.arrayOf(v.isString)}, - - lazy: {validate: v => v.oneOf(v.isWholeNumber, v.isBoolean)}, - }, + lazy: {validate: v => v.oneOf(v.isWholeNumber, v.isBoolean)}, + }, - content(slots) { - 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' */], - }, - }); - }))); - }, - }); + 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' */], + }, + }); + }))); }, }; -- cgit 1.3.0-6-gf8a5