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
|
/** @format */
// Album commentary page and index specifications.
import {filterAlbumsByCommentary} from '../util/wiki-data.js';
export function condition({wikiData}) {
return filterAlbumsByCommentary(wikiData.albumData).length;
}
export function targets({wikiData}) {
return filterAlbumsByCommentary(wikiData.albumData);
}
export function write(album) {
const entries = [album, ...album.tracks]
.filter((x) => x.commentary)
.map((x) => x.commentary);
const words = entries.join(' ').split(' ').length;
const page = {
type: 'page',
path: ['albumCommentary', album.directory],
page: ({
getAlbumStylesheet,
getLinkThemeString,
getThemeString,
html,
language,
link,
transformMultiline,
}) => ({
title: language.$('albumCommentaryPage.title', {album: album.name}),
stylesheet: getAlbumStylesheet(album),
theme: getThemeString(album.color),
main: {
content: html.tag('div', {class: 'long-content'}, [
html.tag('h1', language.$('albumCommentaryPage.title', {
album: link.album(album),
})),
html.tag('p', language.$('albumCommentaryPage.infoLine', {
words: html.tag('b', language.formatWordCount(words, {unit: true})),
entries: html.tag('b', language.countCommentaryEntries(entries.length, {unit: true})),
})),
...html.fragment(album.commentary && [
html.tag('h3', language.$('albumCommentaryPage.entry.title.albumCommentary')),
html.tag('blockquote', transformMultiline(album.commentary)),
]),
...album.tracks.filter(t => t.commentary).flatMap(track => [
html.tag('h3',
{id: 'track.directory'},
language.$('albumCommentaryPage.entry.title.trackCommentary', {
track: link.track(track),
})),
html.tag('blockquote',
{style: getLinkThemeString(track.color)},
transformMultiline(track.commentary)),
])
]),
},
nav: {
linkContainerClasses: ['nav-links-hierarchy'],
links: [
{toHome: true},
{
path: ['localized.commentaryIndex'],
title: language.$('commentaryIndex.title'),
},
{
html: language.$('albumCommentaryPage.nav.album', {
album: link.albumCommentary(album, {class: 'current'}),
}),
},
],
},
}),
};
return [page];
}
export function writeTargetless({wikiData}) {
const data = filterAlbumsByCommentary(wikiData.albumData)
.map((album) => ({
album,
entries: [album, ...album.tracks]
.filter((x) => x.commentary)
.map((x) => x.commentary),
}))
.map(({album, entries}) => ({
album,
entries,
words: entries.join(' ').split(' ').length,
}));
const totalEntries = data.reduce((acc, {entries}) => acc + entries.length, 0);
const totalWords = data.reduce((acc, {words}) => acc + words, 0);
const page = {
type: 'page',
path: ['commentaryIndex'],
page: ({
html,
language,
link,
}) => ({
title: language.$('commentaryIndex.title'),
main: {
content: html.tag('div', {class: 'long-content'}, [
html.tag('h1', language.$('commentaryIndex.title')),
html.tag('p', language.$('commentaryIndex.infoLine', {
words: html.tag('b', language.formatWordCount(totalWords, {unit: true})),
entries: html.tag('b', language.countCommentaryEntries(totalEntries, {unit: true})),
})),
html.tag('p', language.$('commentaryIndex.albumList.title')),
html.tag('ul', data.map(({album, entries, words}) =>
html.tag('li', language.$('commentaryIndex.albumList.item', {
album: link.albumCommentary(album),
words: language.formatWordCount(words, {unit: true}),
entries: language.countCommentaryEntries(entries.length, {unit: true}),
}))))
]),
},
nav: {simple: true},
}),
};
return [page];
}
|