forked from phonegap/phonegap-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docpad.js
110 lines (109 loc) · 3.38 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
var path = require('path');
module.exports = {
"srcPath": ".",
"documentsPaths": [
"docs",
"assets"
],
"filesPaths": [
"public"
],
"layoutsPaths": [
"layouts"
],
"regenerateDelay": 0,
"watchOptions": {
"catchupDelay": 0
},
"templateData": {
"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;
}
return "<!DOCTYPE html>\n<html>\n <head>\n <title>" + (title || 'Redirect') + "</title>\n <meta http-equiv=\"REFRESH\" content=\"0; url=" + url + "\">\n <link rel=\"canonical\" href=\"" + url + "\" />\n </head>\n <body>\n 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>.\n <script>document.location.href = \"" + url + "\"</script>\n </body>\n</html>";
}
},
"stylus": {
"stylusLibraries": {
"nib": false,
"autoprefixer-stylus": true
},
"stylusOptions": {
"compress": true,
"include css": true
}
},
"browsersync": {
"open": true,
"ghostMode": {
"clicks": true,
"location": true,
"forms": true,
"scroll": 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() {
return this.getCollection('gsDocs')
.findAllLive({url:{$startsWith:'phonegap-build/'}}, [{ relativeBase: 1 }])
}
}
};