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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
import {empty} from '#sugar';
export default {
contentDependencies: [
'generateContentHeading',
'generateGroupNavLinks',
'generateGroupSecondaryNav',
'generateGroupSidebar',
'generatePageLayout',
'linkAlbum',
'linkExternal',
'linkGroupGallery',
'linkGroup',
'transformContent',
],
extraDependencies: ['html', 'language', 'wikiData'],
sprawl({wikiInfo}) {
return {
enableGroupUI: wikiInfo.enableGroupUI,
};
},
relations(relation, sprawl, group) {
const relations = {};
const sec = relations.sections = {};
relations.layout =
relation('generatePageLayout');
relations.navLinks =
relation('generateGroupNavLinks', group);
if (sprawl.enableGroupUI) {
relations.secondaryNav =
relation('generateGroupSecondaryNav', group);
relations.sidebar =
relation('generateGroupSidebar', group);
}
sec.info = {};
if (!empty(group.urls)) {
sec.info.visitLinks =
group.urls
.map(url => relation('linkExternal', url));
}
if (group.description) {
sec.info.description =
relation('transformContent', group.description);
}
if (!empty(group.albums)) {
sec.albums = {};
sec.albums.heading =
relation('generateContentHeading');
sec.albums.galleryLink =
relation('linkGroupGallery', group);
sec.albums.entries =
group.albums.map(album => {
const links = {};
links.albumLink = relation('linkAlbum', album);
const otherGroup = album.groups.find(g => g !== group);
if (otherGroup) {
links.groupLink = relation('linkGroup', otherGroup);
}
return links;
});
}
return relations;
},
data(sprawl, group) {
const data = {};
data.name = group.name;
data.color = group.color;
if (!empty(group.albums)) {
data.albumYears =
group.albums
.map(album => album.date?.getFullYear());
}
return data;
},
generate(data, relations, {html, language}) {
const {sections: sec} = relations;
return relations.layout
.slots({
title: language.$('groupInfoPage.title', {group: data.name}),
headingMode: 'sticky',
color: data.color,
mainContent: [
sec.info.visitLinks &&
html.tag('p',
language.$('releaseInfo.visitOn', {
links: language.formatDisjunctionList(sec.info.visitLinks),
})),
html.tag('blockquote',
{[html.onlyIfContent]: true},
sec.info.description
?.slot('mode', 'multiline')),
sec.albums && [
sec.albums.heading
.slots({
tag: 'h2',
title: language.$('groupInfoPage.albumList.title'),
}),
html.tag('p',
language.$('groupInfoPage.viewAlbumGallery', {
link:
sec.albums.galleryLink
.slot('content', language.$('groupInfoPage.viewAlbumGallery.link')),
})),
html.tag('ul',
sec.albums.entries.map(({albumLink, groupLink}, index) => {
// All these strings are really jank, and should probably
// be implemented with the same 'const parts = [], opts = {}'
// form used elsewhere...
const year = data.albumYears[index];
const item =
(year
? language.$('groupInfoPage.albumList.item', {
year,
album: albumLink,
})
: language.$('groupInfoPage.albumList.item.withoutYear', {
album: albumLink,
}));
return html.tag('li',
(groupLink
? language.$('groupInfoPage.albumList.item.withAccent', {
item,
accent:
html.tag('span', {class: 'other-group-accent'},
language.$('groupInfoPage.albumList.item.otherGroupAccent', {
group:
groupLink.slot('color', false),
})),
})
: item));
})),
],
],
...relations.sidebar?.content ?? {},
navLinkStyle: 'hierarchical',
navLinks: relations.navLinks.content,
secondaryNav: relations.secondaryNav ?? null,
});
},
};
|