@nakedcreativity/cee-ms-node 0.2.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -112,20 +112,20 @@ function ceems(config) {
|
|
|
112
112
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
ceems.prototype.load = function(
|
|
115
|
+
ceems.prototype.load = function(req, res){
|
|
116
116
|
|
|
117
|
+
var path = req._parsedUrl.pathname
|
|
117
118
|
this.site = JSON.parse(fs.readFileSync('./pages/site.json', 'utf8'));
|
|
118
|
-
this.pages_map = _.indexBy(this.site.pages, 'url');
|
|
119
|
-
|
|
120
|
-
if(this.
|
|
121
|
-
var page = this.
|
|
119
|
+
//this.pages_map = _.indexBy(this.site.pages, 'url');
|
|
120
|
+
|
|
121
|
+
if(this.site.pages[path]){
|
|
122
|
+
var page = this.site.pages[path]
|
|
122
123
|
|
|
123
124
|
if(page.redirect){
|
|
124
125
|
res.redirect(parseInt(page.redirect.type), page.redirect.to)
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
var page = JSON.parse(fs.readFileSync('./pages/'+page.
|
|
128
|
-
|
|
128
|
+
var page = JSON.parse(fs.readFileSync('./pages/'+page._id+'.json', 'utf8'));
|
|
129
129
|
return page
|
|
130
130
|
|
|
131
131
|
}else{
|
|
@@ -139,7 +139,7 @@ ceems.prototype.load = function(path){
|
|
|
139
139
|
ceems.prototype.render = function(req, res, page=null) {
|
|
140
140
|
|
|
141
141
|
if(!page){
|
|
142
|
-
page = this.load(req
|
|
142
|
+
page = this.load(req, res)
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
// get any external data, and save this into the page
|