@nakedcreativity/cee-ms-node 0.3.11 → 0.3.13

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 +65 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -132,6 +132,71 @@ function ceems(config) {
132
132
  }
133
133
  })
134
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('breadcrumb', {
170
+ parse: function(tagToken, remainTokens) {
171
+ this.template = tagToken.args
172
+ },
173
+ render: function(scope, hash){
174
+
175
+ var breadcrumbArray = []
176
+ var path = ''
177
+ scope.scopes[0].path.forEach(handle => {
178
+ path += handle
179
+ if(site.pages[path]){
180
+ breadcrumbArray.push(site.pages[path])
181
+ path += '/'
182
+ }
183
+ })
184
+
185
+ scope.push({
186
+ breadcrumb: breadcrumbArray
187
+ })
188
+
189
+ return engine.handleCache(this.template+'.liquid')
190
+ .then((templates) => {
191
+ return engine.renderer.renderTemplates(templates, scope);
192
+ })
193
+ .then((html) => {
194
+ scope.pop();
195
+ return html;
196
+ });
197
+ }
198
+ })
199
+
135
200
  this.engine.registerTag('blog', {
136
201
  parse: function(tagToken, remainTokens) {
137
202
  this.match = tagToken.args.split(' ')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nakedcreativity/cee-ms-node",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "description": "Cee.ms for Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {