This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
/
docpad.js
123 lines (118 loc) · 3.34 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
119
120
121
122
123
var path = require('path');
let version = require('./package.json').version;
console.log('generating as docVersion : ' + version);
module.exports = {
"srcPath": ".",
"documentsPaths": [
"docs",
"assets"
],
"filesPaths": [
"public"
],
"layoutsPaths": [
"layouts"
],
"regenerateDelay": 0,
"watchOptions": {
"catchupDelay": 0
},
"templateData": {
"docVersion":version,
"githuburl": function(slug){
var reposlug = (process.env.TRAVIS_REPO_SLUG)? process.env.TRAVIS_REPO_SLUG : "phonegap/phonegap-docs";
var gitbranch = (process.env.TRAVIS_BRANCH)? process.env.TRAVIS_BRANCH : "master";
gitbranch = (process.env.CI_BRANCH)? process.env.CI_BRANCH : gitbranch;
return "https://github.com/"+ reposlug +"/blob/"+ gitbranch +"/docs/"+slug;
}
},
"plugins": {
"cleanurls": {
"trailingSlashes": true,
"static": true,
getRedirectTemplate: function(url, title) {
if(url != "/") {
url = (url.lastIndexOf('/') == url.length - 1)? url : url + "/";
url = (url.indexOf('/') == 0)? url: "/" + url;
}
let retTemplate =
`<!DOCTYPE html>
<html>
<head>
<title>${title || 'Redirect'}</title>
<meta http-equiv="REFRESH" content="0; url=${url}">
<link rel="canonical" href="${url}"/>
</head>
<body>
This page has moved. You will be automatically redirected to its new location.
If you aren't forwarded to the new page, <a href="${url}">click here</a>.
<script>document.location.href="${url}"</script>
</body>
</html>`;
return retTemplate;
}
},
"stylus": {
"stylusLibraries": {
"nib": false,
"autoprefixer-stylus": true
},
"stylusOptions": {
"compress": true,
"include css": true
}
}
},
"environments": {
"development": {
"stylusOptions": {
"compress": false
}
}
},
"ignorePaths": [
/**
* Ignore output directory to prevent watch triggering
* when outPath is written. This happens because srcPath
* is the rootPath instead of a subdirectory.
*/
path.join(process.cwd(), "out")
],
"collections": {
/**
* Set default layout for all markdown documents.
*/
navItems: function() {
return this.getCollection('html')
.findAllLive({}, [{ fullPath:1 }]);
},
docs: function() {
return this.getCollection('documents')
.findAllLive({ extension: 'md' }, [{ filename: -1 }])
.on('add', function(model) {
model.setMetaDefaults({ 'layout': 'default' });
});
},
gsDocs: function() {
return this.getCollection('html')
.findAllLive({ extension: 'md' })
},
getStartedDocs: function() {
return this.getCollection('gsDocs')
.findAllLive({url: {$startsWith:'getting-started/' }}, [{ relativeBase: 1 }])
},
referenceDocs: function() {
return this.getCollection('gsDocs')
.findAllLive({url: {$startsWith:'references/' }}, [{ relativeBase: 1 }])
},
tutorialDocs: function() {
return this.getCollection('gsDocs')
.findAllLive({url:{$startsWith:'tutorials/'}}, [{ relativeBase: 1 }])
},
pgbDocs: function() {
let retVal = this.getCollection('gsDocs')
.findAllLive({url:{$startsWith:'phonegap-build/'}}, [{ relativeBase: 1 }]);
return retVal;
}
}
};