-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (42 loc) · 1.27 KB
/
index.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
var fs = require('fs');
var Q = require('q');
var path = require('path');
var _counter = 1;
var _currentPage;
module.exports = {
website: {
assets: "./assets"
},
hooks: {
"page:before": function(page) {
_currentPage = page;
return page;
}
},
blocks: {
zingchart: {
process: function(block) {
if (this.output.name === 'website') {
var id = 'zingchart-' + _counter++;
var div = '<div id="' + id + '"></div>';
var args = block.kwargs;
var obj = {id: id};
if (block.body.trim() !== '') {
obj.data = block.body;
}
for (var key in args) {
if (args.hasOwnProperty(key)) {
var name = (key === 'src') ? 'dataurl' : key;
obj[name] = args[key];
}
}
var script = "<script>zingchart.render(" + JSON.stringify(obj) + ");</script>";
return div + script;
}
else{
return '';
}
}
}
}
};