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
|
// Art tag page specification.
export function condition({wikiData}) {
return wikiData.wikiInfo.enableArtTagUI;
}
export function targets({wikiData}) {
return wikiData.artTagData.filter((tag) => !tag.isContentWarning);
}
export function write(tag, {wikiData}) {
const {taggedInThings: things} = tag;
// Display things featuring this art tag in reverse chronological order,
// sticking the most recent additions near the top!
const thingsReversed = things.slice().reverse();
const entries = thingsReversed.map((item) => ({item}));
const page = {
type: 'page',
path: ['tag', tag.directory],
page: ({
getAlbumCover,
getGridHTML,
getThemeString,
getTrackCover,
html,
language,
link,
}) => ({
title: language.$('tagPage.title', {tag: tag.name}),
theme: getThemeString(tag.color),
main: {
classes: ['top-index'],
content: [
html.tag('h1',
language.$('tagPage.title', {
tag: tag.name,
})),
html.tag('p',
{class: 'quick-info'},
language.$('tagPage.infoLine', {
coverArts: language.countCoverArts(things.length, {
unit: true,
}),
})),
html.tag('div',
{class: 'grid-listing'},
getGridHTML({
entries,
srcFn: (thing) =>
thing.album
? getTrackCover(thing)
: getAlbumCover(thing),
linkFn: (thing, opts) =>
thing.album
? link.track(thing, opts)
: link.album(thing, opts),
})),
],
},
nav: generateTagNav(tag, {
link,
language,
wikiData,
}),
}),
};
return [page];
}
// Utility functions
function generateTagNav(tag, {
language,
link,
wikiData,
}) {
return {
linkContainerClasses: ['nav-links-hierarchy'],
links: [
{toHome: true},
wikiData.wikiInfo.enableListings && {
path: ['localized.listingIndex'],
title: language.$('listingIndex.title'),
},
{
html: language.$('tagPage.nav.tag', {
tag: link.tag(tag, {class: 'current'}),
}),
},
],
};
}
|