1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import {stitchArrays} from '../../util/sugar.js';
export default {
extraDependencies: ['html'],
slots: {
images: {validate: v => v.arrayOf(v.isHTML)},
links: {validate: v => v.arrayOf(v.isHTML)},
names: {validate: v => v.arrayOf(v.isString)},
info: {validate: v => v.arrayOf(v.isString)},
lazy: {validate: v => v.oneOf(v.isWholeNumber, v.isBoolean)},
},
generate(slots, {html}) {
return (
html.tag('div', {class: 'grid-listing'},
stitchArrays({
image: slots.images,
link: slots.links,
name: slots.names,
info: slots.info,
}).map(({image, link, name, info}, 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', {[html.onlyIfContent]: true}, name),
html.tag('span', {[html.onlyIfContent]: true}, info),
],
}))));
},
};
|