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
|
// Art tag page specification.
// Imports
import fixWS from 'fix-whitespace';
// Page exports
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 { wikiInfo } = 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: ({
generatePreviousNextLinks,
getAlbumCover,
getGridHTML,
getThemeString,
getTrackCover,
link,
strings,
to
}) => ({
title: strings('tagPage.title', {tag: tag.name}),
theme: getThemeString(tag.color),
main: {
classes: ['top-index'],
content: fixWS`
<h1>${strings('tagPage.title', {tag: tag.name})}</h1>
<p class="quick-info">${strings('tagPage.infoLine', {
coverArts: strings.count.coverArts(things.length, {unit: true})
})}</p>
<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))
})}
</div>
`
},
nav: generateTagNav(tag, {
generatePreviousNextLinks,
link,
strings,
wikiData
})
})
};
return [page];
}
// Utility functions
function generateTagNav(tag, {
generatePreviousNextLinks,
link,
strings,
wikiData
}) {
const previousNextLinks = generatePreviousNextLinks(tag, {
data: wikiData.artTagData.filter(tag => !tag.isContentWarning),
linkKey: 'tag'
});
return {
links: [
{toHome: true},
wikiData.wikiInfo.enableListings &&
{
path: ['localized.listingIndex'],
title: strings('listingIndex.title')
},
{
html: strings('tagPage.nav.tag', {
tag: link.tag(tag, {class: 'current'})
})
},
/*
previousNextLinks && {
divider: false,
html: `(${previousNextLinks})`
}
*/
]
};
}
|