forked from Semantic-Org/Semantic-UI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocpad.js
118 lines (115 loc) · 3.49 KB
/
docpad.js
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
(function() {
var docpadConfig;
docpadConfig = {
srcPath: './server',
outPath: './docs',
templateData: {
site: {
url: "http://www.semantic-ui.com",
oldUrls: ['learnsemantic.com'],
title: "Semantic UI",
description: "Semantic empowers designers and developers by creating a shared vocabulary for UI.",
keywords: "html5, ui, library, framework, javascript"
},
getPreparedTitle: function() {
if (this.document.title) {
return "" + this.document.title + " | " + this.site.title;
} else {
return this.site.title;
}
},
getPage: function(collection, id) {
var index, item, selectedIndex, _i, _len;
for (index = _i = 0, _len = collection.length; _i < _len; index = ++_i) {
item = collection[index];
if (item.id === id) {
selectedIndex = index + 1;
}
}
return selectedIndex;
},
pageCount: function(collection) {
var index, item, itemCount, _i, _len;
for (index = _i = 0, _len = collection.length; _i < _len; index = ++_i) {
item = collection[index];
itemCount = index + 1;
}
return itemCount;
},
getPageCollection: function(collection, id, delta) {
var bottomCount, bottomDelta, bottomIndex, index, item, lastIndex, result, selectedIndex, topCount, topDelta, topIndex, _i, _len;
if (delta == null) {
delta = 2;
}
for (index = _i = 0, _len = collection.length; _i < _len; index = ++_i) {
item = collection[index];
if (item.id === id) {
selectedIndex = index;
}
lastIndex = index;
}
bottomCount = selectedIndex - delta >= 0 ? delta : selectedIndex;
topCount = selectedIndex + delta <= lastIndex ? delta : lastIndex - selectedIndex;
bottomDelta = delta * 2 - topCount;
topDelta = delta * 2 - bottomCount;
bottomIndex = selectedIndex - bottomDelta >= 0 ? selectedIndex - bottomDelta : 0;
topIndex = selectedIndex + topDelta <= lastIndex ? selectedIndex + topDelta : lastIndex;
result = collection.slice(bottomIndex, +topIndex + 1 || 9e9);
return result;
},
getPreparedDescription: function() {
return this.document.description || this.site.description;
},
getPreparedKeywords: function() {
return this.site.keywords.concat(this.document.keywords || []).join(', ');
}
},
collections: {
uiElements: function() {
return this.getCollection("documents").findAllLive({
type: {
$in: ['UI Element']
}
}, [
{
title: 1
}
]);
},
uiCollections: function() {
return this.getCollection("documents").findAllLive({
type: {
$in: ['UI Collection']
}
}, [
{
title: 1
}
]);
},
uiViews: function() {
return this.getCollection("documents").findAllLive({
type: {
$in: ['UI View']
}
}, [
{
title: 1
}
]);
},
uiModules: function() {
return this.getCollection("documents").findAllLive({
type: {
$in: ['UI Module', 'UI Behavior']
}
}, [
{
title: 1
}
]);
}
}
};
module.exports = docpadConfig;
}).call(this);