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
|
export default {
contentDependencies: [
'generateColorStyleVariables',
'linkArtist',
'transformContent',
],
extraDependencies: ['html', 'language'],
relations: (relation, entry) => ({
artistLink:
(entry.artist && !entry.artistDisplayText
? relation('linkArtist', entry.artist)
: null),
artistsContent:
(entry.artistDisplayText
? relation('transformContent', entry.artistDisplayText)
: null),
annotationContent:
(entry.annotation
? relation('transformContent', entry.annotation)
: null),
bodyContent:
(entry.body
? relation('transformContent', entry.body)
: null),
colorVariables:
relation('generateColorStyleVariables'),
}),
data: (entry) => ({
date: entry.date,
}),
slots: {
color: {validate: v => v.isColor},
},
generate(data, relations, slots, {html, language}) {
const artistsSpan =
html.tag('span', {class: 'commentary-entry-artists'},
(relations.artistsContent
? relations.artistsContent.slot('mode', 'inline')
: relations.artistLink
? relations.artistLink
: language.$('misc.artistCommentary.entry.title.noArtists')));
const accentParts = ['misc.artistCommentary.entry.title.accent'];
const accentOptions = {};
if (relations.annotationContent) {
accentParts.push('withAnnotation');
accentOptions.annotation =
relations.annotationContent.slot('mode', 'inline');
}
if (data.date) {
accentParts.push('withDate');
accentOptions.date =
language.formatDate(data.date);
}
const accent =
(accentParts.length > 1
? html.tag('span', {class: 'commentary-entry-accent'},
language.$(...accentParts, accentOptions))
: null);
const titleParts = ['misc.artistCommentary.entry.title'];
const titleOptions = {artists: artistsSpan};
if (accent) {
titleParts.push('withAccent');
titleOptions.accent = accent;
}
const style =
(slots.color
? relations.colorVariables
.slot('color', slots.color)
.content
: null);
return html.tags([
html.tag('p', {class: 'commentary-entry-heading', style},
language.$(...titleParts, titleOptions)),
html.tag('blockquote', {class: 'commentary-entry-body', style},
relations.bodyContent.slot('mode', 'multiline')),
]);
},
};
|