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
|
import {stitchArrays} from '#sugar';
export default {
contentDependencies: ['generateCoverCarousel', 'image', 'linkAlbum'],
relations: (relation, row) => ({
coverCarousel:
relation('generateCoverCarousel'),
links:
row.albums
.map(album => relation('linkAlbum', album)),
images:
row.albums
.map(album => relation('image', album.artTags)),
}),
data: (row) => ({
paths:
row.albums.map(album =>
(album.hasCoverArt
? ['media.albumCover', album.directory, album.coverArtFileExtension]
: null)),
}),
generate: (data, relations) =>
relations.coverCarousel.slots({
links:
relations.links,
images:
stitchArrays({
image: relations.images,
path: data.paths,
}).map(({image, path}) =>
image.slot('path', path)),
}),
};
|