-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.js
33 lines (27 loc) · 837 Bytes
/
doc.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
var colours = require('./build/g-chartcolour.js');
var fs = require('fs');
var nunjucks = require('nunjucks');
console.log('building docs');
var normalisedPalettes = Object.keys(colours)
.map(function(key){
var col;
if(Array.isArray(colours[key])){
col = colours[key].map((d,i)=>({
name:i,
colour:d
}));
}else{
col = Object.keys(colours[key]).map((d)=>({
name:d,
colour:colours[key][d]
}));
}
return {
name:key,
colours:col,
}
});
context = {
palettes: normalisedPalettes,
};
fs.writeFileSync('index.html',nunjucks.render('./templates/index.njk.html', context));