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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
// Homepage specification.
import {
bindOpts,
empty,
withEntries,
} from '../util/sugar.js';
import {
getNewAdditions,
getNewReleases,
} from '../util/wiki-data.js';
export function writeTargetless({wikiData}) {
const {newsData, homepageLayout, wikiInfo} = wikiData;
const rowData = homepageLayout.rows?.map(row => {
const {color, name, type} = row;
const entry = {row, color, name, type};
switch (type) {
case 'albums': {
entry.displayStyle = row.displayStyle;
switch (row.sourceGroupByRef) {
case 'new-releases':
entry.entries = getNewReleases(row.countAlbumsFromGroup, {wikiData});
break;
case 'new-additions':
entry.entries = getNewAdditions(row.countAlbumsFromGroup, {wikiData});
break;
default:
entry.entries = row.sourceGroup
? row.sourceGroup.albums
.slice()
.reverse()
.filter(album => album.isListedOnHomepage)
.slice(0, row.countAlbumsFromGroup)
.map(album => ({item: album}))
: [];
}
if (!empty(row.sourceAlbums)) {
entry.entries.push(...row.sourceAlbums.map(album => ({item: album})));
}
entry.actionLinks = row.actionLinks ?? [];
break;
}
}
return entry;
});
const transformActionLinks = (actionLinks, {
transformInline,
}) =>
actionLinks?.map(transformInline)
.map(a => a.replace('<a', '<a class="box grid-item"'));
const page = {
type: 'page',
path: ['home'],
page: ({
getAlbumGridHTML,
getAlbumCover,
getCarouselHTML,
getLinkThemeString,
html,
language,
link,
to,
transformInline,
transformMultiline,
}) => ({
title: wikiInfo.name,
showWikiNameInTitle: false,
meta: {
description: wikiInfo.description,
},
main: {
classes: ['top-index'],
content: html.fragment([
html.tag('h1',
wikiInfo.name),
...html.fragment(
rowData.map((entry, i) =>
html.tag('section',
{
class: 'row',
style: getLinkThemeString(entry.color),
},
[
html.tag('h2',
entry.name),
entry.type === 'albums' &&
entry.displayStyle === 'grid' &&
html.tag('div', {class: 'grid-listing'}, [
...html.fragment(
getAlbumGridHTML({
entries: entry.entries,
lazy: i > 0,
})),
html.tag('div',
{
[html.onlyIfContent]: true,
class: 'grid-actions',
},
transformActionLinks(entry.actionLinks, {
transformInline,
})),
]),
...html.fragment(
entry.type === 'albums' &&
entry.displayStyle === 'carousel' && [
getCarouselHTML({
items: entry.entries.map(e => e.item),
// Lazy carousels are kinda glitchy, possibly browser-dependant
// lazy: i > 0,
srcFn: getAlbumCover,
linkFn: link.album,
}),
entry.actionLinks.length &&
html.tag('div', {class: 'grid-actions'},
transformActionLinks(entry.actionLinks, {
transformInline,
})),
]),
]))),
]),
},
sidebarLeft: homepageLayout.sidebarContent && {
wide: true,
collapse: false,
stickyMode: 'none',
// This is a pretty filthy hack! 8ut otherwise, the [[news]] part
// gets treated like it's a reference to the track named "news",
// which o8viously isn't what we're going for. Gotta catch that
// 8efore we pass it to transformMultiline, 'cuz otherwise it'll
// get repl8ced with just the word "news" (or anything else that
// transformMultiline does with references it can't match) -- and
// we can't match that for replacing it with the news column!
//
// And no, I will not make [[news]] into part of transformMultiline
// (even though that would 8e hilarious).
content:
transformMultiline(
homepageLayout.sidebarContent
.replace('[[news]]', '__GENERATE_NEWS__'),
{
thumb: 'medium',
})
.replace('<p>__GENERATE_NEWS__</p>',
wikiInfo.enableNews
? [
html.tag('h1',
language.$('homepage.news.title')),
...newsData
.slice(0, 3)
.map((entry, i) =>
html.tag('article',
{
class: [
'news-entry',
i === 0 && 'first-news-entry',
],
},
[
html.tag('h2', [
html.tag('time',
language.formatDate(entry.date)),
link.newsEntry(entry),
]),
transformMultiline(entry.contentShort, {
thumb: 'medium',
}),
entry.contentShort !== entry.content &&
link.newsEntry(entry, {
text: language.$('homepage.news.entry.viewRest')
}),
])),
].join('\n')
: html.tag('p',
html.tag('i',
`News requested in content description but this feature isn't enabled`))),
},
nav: {
linkContainerClasses: ['nav-links-index'],
links: [
link.home('', {text: wikiInfo.nameShort, class: 'current', to}),
...html.fragment(
homepageLayout.navbarLinks?.map(text =>
transformInline(text, {
link:
withEntries(link, entries =>
entries.map(([key, fn]) =>
[key, bindOpts(fn, {
preferShortName: true,
})])),
}))),
]
.filter(Boolean)
.map((html) => ({html})),
},
}),
};
return [page];
}
|