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
|
export default {
contentDependencies: [
'generateAlbumSidebarTrackSection',
'generatePageSidebar',
'generatePageSidebarBox',
'linkAlbum',
],
extraDependencies: ['html', 'language'],
relations: (relation, album) => ({
sidebar:
relation('generatePageSidebar'),
sidebarBox:
relation('generatePageSidebarBox'),
albumLink:
relation('linkAlbum', album),
trackSections:
album.trackSections.map(trackSection =>
relation('generateAlbumSidebarTrackSection',
album,
null,
trackSection)),
}),
data: (album) => ({
albumHasCommentary:
!!album.commentary,
anyTrackHasCommentary:
album.tracks.some(track => track.commentary),
}),
generate: (data, relations, {html, language}) =>
language.encapsulate('albumCommentaryPage', pageCapsule =>
relations.sidebar.slots({
stickyMode: 'column',
boxes: [
relations.sidebarBox.slots({
attributes: {class: 'commentary-track-list-sidebar-box'},
content: [
html.tag('h1', relations.albumLink),
html.tag('p', {[html.onlyIfContent]: true},
language.encapsulate(pageCapsule, 'sidebar', workingCapsule => {
if (data.anyTrackHasCommentary) return html.blank();
if (data.albumHasCommentary) {
workingCapsule += '.noTrackCommentary';
} else {
workingCapsule += '.noCommentary';
}
return language.$(workingCapsule);
})),
data.anyTrackHasCommentary &&
relations.trackSections.map(section =>
section.slots({
anchor: true,
open: true,
mode: 'commentary',
})),
],
}),
]
})),
}
|