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
|
import {stitchArrays} from '#sugar';
export default {
contentDependencies: [
'generateAbsoluteDatetimestamp',
'generateColorStyleAttribute',
'generateRelativeDatetimestamp',
'linkAlbum',
'linkTrack',
],
extraDependencies: ['html', 'language'],
relations: (relation, track) => ({
colorStyles:
track.otherReleases
.map(track => relation('generateColorStyleAttribute', track.color)),
trackLinks:
track.otherReleases
.map(track => relation('linkTrack', track)),
albumLinks:
track.otherReleases
.map(track => relation('linkAlbum', track.album)),
datetimestamps:
track.otherReleases.map(track2 =>
(track2.date
? (track.date
? relation('generateRelativeDatetimestamp',
track2.date,
track.date)
: relation('generateAbsoluteDatetimestamp',
track2.date))
: null)),
items:
track.otherReleases.map(track => ({
trackLink: relation('linkTrack', track),
albumLink: relation('linkAlbum', track.album),
})),
}),
generate: (relations, {html, language}) =>
html.tag('ul',
{[html.onlyIfContent]: true},
stitchArrays({
trackLink: relations.trackLinks,
albumLink: relations.albumLinks,
datetimestamp: relations.datetimestamps,
colorStyle: relations.colorStyles,
}).map(({
trackLink,
albumLink,
datetimestamp,
colorStyle,
}) => {
const parts = ['releaseInfo.alsoReleasedAs.item'];
const options = {};
options.track = trackLink.slot('color', false);
options.album = albumLink;
if (datetimestamp) {
parts.push('withYear');
options.year =
datetimestamp.slots({
style: 'year',
tooltip: true,
});
}
return (
html.tag('li',
colorStyle,
language.$(...parts, options)));
})),
};
|