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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
import {empty, stitchArrays} from '#sugar';
import {getNewAdditions, getNewReleases} from '#wiki-data';
export default {
contentDependencies: ['generateCoverGrid', 'image', 'linkAlbum'],
extraDependencies: ['language', 'wikiData'],
sprawl({albumData}, row) {
const sprawl = {};
switch (row.sourceGroup) {
case 'new-releases':
sprawl.albums = getNewReleases(row.countAlbumsFromGroup, {albumData});
break;
case 'new-additions':
sprawl.albums = getNewAdditions(row.countAlbumsFromGroup, {albumData});
break;
default:
sprawl.albums =
(row.sourceGroup
? row.sourceGroup.albums
.slice()
.reverse()
.filter(album => album.isListedOnHomepage)
.slice(0, row.countAlbumsFromGroup)
: []);
}
if (!empty(row.sourceAlbums)) {
sprawl.albums.push(...row.sourceAlbums);
}
return sprawl;
},
relations: (relation, sprawl, _row) => ({
coverGrid:
relation('generateCoverGrid'),
links:
sprawl.albums
.map(album => relation('linkAlbum', album)),
images:
sprawl.albums
.map(album =>
relation('image',
(album.hasCoverArt
? album.coverArtworks[0]
: null))),
}),
data: (sprawl, _row) => ({
names:
sprawl.albums
.map(album => album.name),
}),
generate: (data, relations, {language}) =>
relations.coverGrid.slots({
links: relations.links,
names: data.names,
images:
stitchArrays({
image: relations.images,
name: data.names,
}).map(({image, name}) =>
image.slots({
missingSourceContent:
language.$('misc.coverGrid.noCoverArt', {
album: name,
}),
})),
}),
};
|