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
79
80
81
82
83
84
85
86
87
88
89
90
|
import {stitchArrays} from '#sugar';
export default {
contentDependencies: [
'generateCoverGrid',
'image',
'linkAlbum',
],
extraDependencies: ['html', 'language'],
query: (album) => ({
artworks:
(album.hasCoverArt
? album.coverArtworks
: []),
}),
relations: (relation, query, album) => ({
coverGrid:
relation('generateCoverGrid'),
albumLinks:
query.artworks.map(_artwork =>
relation('linkAlbum', album)),
images:
query.artworks
.map(artwork => relation('image', artwork)),
}),
data: (query, album) => ({
albumName:
album.name,
artworkLabels:
query.artworks
.map(artwork => artwork.label),
artworkArtists:
query.artworks
.map(artwork => artwork.artistContribs
.map(contrib => contrib.artist.name)),
}),
slots: {
attributes: {type: 'attributes', mutable: false},
},
generate: (data, relations, slots, {html, language}) =>
html.tag('div',
{[html.onlyIfContent]: true},
slots.attributes,
[
relations.coverArtistsLine,
relations.coverGrid.slots({
links:
relations.albumLinks,
names:
data.artworkLabels
.map(label => label ?? data.albumName),
images:
stitchArrays({
image: relations.images,
label: data.artworkLabels,
}).map(({image, label}) =>
image.slots({
missingSourceContent:
language.$('misc.albumGalleryGrid.noCoverArt', {
name:
label ?? data.albumName,
}),
})),
info:
data.artworkArtists.map(artists =>
language.$('misc.coverGrid.details.coverArtists', {
[language.onlyIfOptions]: ['artists'],
artists:
language.formatUnitList(artists),
})),
}),
]),
};
|