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 {sortChronologically} from '#sort';
import {stitchArrays} from '#sugar';
export default {
contentDependencies: ['generateColorStyleAttribute', 'generateTooltip'],
extraDependencies: ['html', 'language'],
query: (track) => ({
rereleases:
sortChronologically(track.allReleases).slice(1),
}),
relations: (relation, query, track) => ({
tooltip:
relation('generateTooltip'),
firstReleaseColorStyle:
relation('generateColorStyleAttribute', track.color),
rereleaseColorStyles:
query.rereleases
.map(rerelease =>
relation('generateColorStyleAttribute', rerelease.album.color)),
}),
data: (query, track) => ({
firstReleaseDate:
track.dateFirstReleased ??
track.album.date,
rereleaseAlbumNames:
query.rereleases
.map(rerelease => rerelease.album.name),
rereleaseDates:
query.rereleases
.map(rerelease =>
rerelease.dateFirstReleased ??
rerelease.album.date),
}),
generate: (data, relations, {html, language}) =>
language.encapsulate('artistPage.creditList.entry.firstRelease', capsule =>
relations.tooltip.slots({
attributes: [
{class: 'first-release-tooltip'},
relations.firstReleaseColorStyle,
],
contentAttributes: [
{[html.joinChildren]: html.tag('hr', {class: 'cute'})},
],
content:
stitchArrays({
colorStyle: relations.rereleaseColorStyles,
albumName: data.rereleaseAlbumNames,
date: data.rereleaseDates,
}).map(({colorStyle, albumName, date}) =>
html.tags([
language.$(capsule, 'rerelease', {
album:
html.metatag('blockwrap',
html.tag('a',
{href: '#'},
colorStyle.slot('context', 'primary-only'),
language.sanitize(albumName))),
}),
html.tag('br'),
language.formatRelativeDate(date, data.firstReleaseDate, {
considerRoundingDays: true,
approximate: true,
absolute: true,
}),
])),
})),
};
|