-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfractal.js
66 lines (52 loc) · 1.44 KB
/
fractal.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
/*
* Require some core modules
*/
const path = require('path');
const fs = require('fs');
/*
* Require the Fractal module
*/
const twig = require('@frctl/twig');
const fractal = module.exports = require('@frctl/fractal').create();
/*
* Give your project a title.
*/
fractal.set('project.title', 'ClearFractal');
/*
* Tell Fractal where to look for components.
*/
fractal.components.set('path', `${__dirname}/components`);
fractal.components.set('ext', '.twig');
fractal.components.engine(twig({
// importContext: true
}));
/*
* Tell Fractal where to look for documentation pages.
*/
fractal.docs.set('path', path.join(__dirname, 'docs'));
/*
* Tell the Fractal web preview plugin where to look for static assets.
*/
fractal.web.set('static.path', `${__dirname}/public`);
fractal.web.set('builder.dest', __dirname + '/build');
fractal.set('components.default.preview', '@skeleton');
const theme = require('@frctl/mandelbrot')();
fractal.web.theme(theme);
/*
* Handle => filesystem path mapping export.
*/
function exportPaths() {
const map = {};
for (let item of fractal.components.flatten()) {
map[`@${item.handle}`] = path.relative(process.cwd(), item.viewPath);
}
fs.writeFileSync('components-map.json', JSON.stringify(map, null, 2), 'utf8');
}
fractal.components.on('updated', function(){
exportPaths();
});
fractal.cli.command('pathmap', function(opts, done){
exportPaths();
done();
});