-
Notifications
You must be signed in to change notification settings - Fork 513
/
SubpagesWithSummaries.ejs
46 lines (36 loc) · 1.04 KB
/
SubpagesWithSummaries.ejs
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
<%
// Creates a list of the subpages of the current page, with their summaries,
// as a definition list. Doesn't do any additional formatting.
//
// Parameters:
//
// $0 A list of pages to output instead of the subpages of the current page;
// OPTIONAL.
function pageSorter(a, b) {
return a.title.localeCompare(b.title);
}
var termList;
var html = "";
if ($0 && ($0 != undefined)) {
termList = JSON.parse($0);
} else {
termList = await page.subpagesExpand();
}
var numTerms = termList.length;
if (numTerms) {
// Alphabetize the list
termList.sort(pageSorter);
html += "<dl>";
for (var i=0; i<numTerms; i++) {
var aPage = termList[i];
if (aPage.title != "Index") {
var title = aPage.title;
var summary = aPage.summary().replace(/<img[^>]*>/g," ");
var url = aPage.url;
html += "<dt class='landingPageList'><a href='" + url + "'>" + title + "</a></dt><dd class='landingPageList'><p>" + summary + "</p></dd>";
}
}
html += "</dl>";
}
%>
<%-html%>