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
|
import {stitchArrays} from '#sugar';
import {getTotalDuration} from '#wiki-data';
export default {
contentDependencies: [
'generateArtistInfoPageChunk',
'generateArtistInfoPageTracksChunkItem',
'linkAlbum',
],
relations: (relation, artist, album, tracks, contribs) => ({
template:
relation('generateArtistInfoPageChunk'),
albumLink:
relation('linkAlbum', album),
items:
stitchArrays({
track: tracks,
contribs: contribs,
}).map(({track, contribs}) =>
relation('generateArtistInfoPageTracksChunkItem',
artist,
track,
contribs)),
}),
data: (_artist, album, tracks, _contribs) => ({
// STUB: This is flat-out incorrect date behavior.
date:
album.date,
duration:
getTotalDuration(tracks, {originalReleasesOnly: true}),
durationApproximate:
tracks
.filter(track => track.duration && track.isOriginalRelease)
.length > 1,
}),
generate: (data, relations) =>
relations.template.slots({
mode: 'album',
albumLink: relations.albumLink,
date: data.date,
duration: data.duration,
durationApproximate: data.durationApproximate,
items: relations.items,
}),
};
|