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
|
import {empty} from '../../util/sugar.js';
export default {
contentDependencies: [
'generatePageLayout',
'linkListing',
'linkListingIndex',
],
extraDependencies: ['html', 'language', 'wikiData'],
sprawl({listingSpec}) {
return {listingSpec};
},
query(sprawl, listing) {
return {
seeAlso:
(listing.seeAlso
? listing.seeAlso.map(directory =>
sprawl.listingSpec
.find(listing => listing.directory === directory))
: null),
};
},
relations(relation, query) {
const relations = {};
relations.layout =
relation('generatePageLayout');
relations.listingsIndexLink =
relation('linkListingIndex');
if (!empty(query.seeAlso)) {
// TODO: Invalid listing directories filtered here aren't warned about anywhere.
// Honestly we shouldn't be searching listingSpec here at all - listings should
// be implemented as proper things which search listingSpec themselves, and
// expose seeAlso as a list of listing objects rather than by reference.
relations.seeAlsoLinks =
query.seeAlso
.map(listing => relation('linkListing', listing))
.filter(Boolean);
}
return relations;
},
data(query, sprawl, listing) {
return {
stringsKey: listing.stringsKey,
};
},
slots: {
type: {
validate: v => v.is('rows'),
},
rows: {
validate: v => v.arrayOf(v.isObject),
},
},
generate(data, relations, slots, {html, language}) {
return relations.layout.slots({
title: language.$(`listingPage.${data.stringsKey}.title`),
headingMode: 'sticky',
mainContent: [
relations.seeAlsoLinks &&
html.tag('p',
language.$('listingPage.seeAlso', {
listings: language.formatUnitList(relations.seeAlsoLinks),
})),
slots.type === 'rows' &&
html.tag('ul',
slots.rows.map(row =>
html.tag('li',
language.$(`listingPage.${data.stringsKey}.item`, row)))),
],
navLinkStyle: 'hierarchical',
navLinks: [
{auto: 'home'},
{html: relations.listingsIndexLink},
{auto: 'current'},
],
});
},
};
|