@nakedcreativity/cee-ms-node 0.3.10 → 0.3.12

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.
Files changed (2) hide show
  1. package/index.js +64 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -66,7 +66,7 @@ function ceems(config) {
66
66
  this.match = tagToken.args.split(' '); // name // path[0] == navigation name
67
67
  },
68
68
  render: function(scope, hash){
69
- var filepath = Liquid.evalValue(this.match[1]+'.liquid', scope);
69
+ //var filepath = Liquid.evalValue(this.match[1]+'.liquid', scope);
70
70
  var page = scope.scopes[0]
71
71
 
72
72
  if(page.path && this.match[0] == 'page.path[0]' && site.navigation[page.path[0]]){
@@ -98,9 +98,7 @@ function ceems(config) {
98
98
  // var filepath = Liquid.evalValue(this.match[1]+'.liquid', scope);
99
99
  var page = scope.scopes[0]
100
100
 
101
- console.log('look for page with handle', this.match[0])
102
- var site = JSON.parse(fs.readFileSync('./pages/site.json', 'utf8'));
103
- console.log(site)
101
+ console.log('look for page with path', this.match[0])
104
102
 
105
103
  if(site.pages[this.match[0]]){
106
104
  var page = site.pages[this.match[0]]
@@ -113,6 +111,7 @@ function ceems(config) {
113
111
  page.fullpath = site.pages[this.match[0]].url
114
112
  page.path = page.fullpath.split('/')
115
113
 
114
+ console.log(page)
116
115
  scope.push(page)
117
116
 
118
117
  return engine.handleCache(this.match[1]+'.liquid')
@@ -133,6 +132,67 @@ function ceems(config) {
133
132
  }
134
133
  })
135
134
 
135
+ this.engine.registerTag('data', {
136
+ parse: function(tagToken, remainTokens) {
137
+ this.match = tagToken.args.split(' '); // name // path[0] == navigation name
138
+ },
139
+ render: function(scope, hash){
140
+ // var filepath = Liquid.evalValue(this.match[1]+'.liquid', scope);
141
+
142
+ console.log('look for data collection', this.match[0])
143
+
144
+ if(site.collections[this.match[0]]){
145
+ console.log(site.collections[this.match[0]]._id)
146
+ var collection = JSON.parse(fs.readFileSync('./data/'+site.collections[this.match[0]]._id+'.json', 'utf8'));
147
+
148
+ var scopeObj = {}
149
+ scopeObj[this.match[0]] = collection.data
150
+ scope.push(scopeObj)
151
+
152
+ console.log(scope)
153
+
154
+ return engine.handleCache(this.match[1]+'.liquid')
155
+ .then((templates) => {
156
+ return engine.renderer.renderTemplates(templates, scope);
157
+ })
158
+ .then((html) => {
159
+ scope.pop();
160
+ return html;
161
+ });
162
+
163
+ }else {
164
+ return
165
+ }
166
+ }
167
+ })
168
+
169
+ this.engine.registerTag('blog', {
170
+ parse: function(tagToken, remainTokens) {
171
+ this.match = tagToken.args.split(' ')
172
+ },
173
+ render: function(scope, hash){
174
+
175
+ console.log('render blog', this.match[0])
176
+ console.log(site.blogs[this.match[0]])
177
+
178
+ if(!site.blogs[this.match[0]]){
179
+ console.log('no match')
180
+ return
181
+ }
182
+ console.log(this.match[1], 'look for liquid template')
183
+ scope.push(site.blogs[this.match[0]])
184
+ return engine.handleCache(this.match[1]+'.liquid')
185
+ .then((templates) => {
186
+ return engine.renderer.renderTemplates(templates, scope);
187
+ })
188
+ .then((html) => {
189
+ scope.pop();
190
+ return html;
191
+ });
192
+ }
193
+
194
+ })
195
+
136
196
 
137
197
  this.app.listen(config.port, function () {});
138
198
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakedcreativity/cee-ms-node",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Cee.ms for Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {