-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
48 lines (44 loc) · 1.3 KB
/
setup.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
var Metalsmith = require('metalsmith');
var ignore = require('metalsmith-ignore');
var markdown = require('metalsmith-markdown');
var templates = require('metalsmith-templates');
var sass = require('metalsmith-sass');
var imagemin = require('metalsmith-imagemin');
var Handlebars = require('handlebars');
var fs = require('fs');
Handlebars.registerPartial(
'header',
fs.readFileSync(__dirname + '/templates/partials/header.hbt').toString()
);
Handlebars.registerPartial(
'footer',
fs.readFileSync(__dirname + '/templates/partials/footer.hbt').toString()
);
Handlebars.registerHelper(
'activeClass',
function (currentPermalink, expectedPermalink, depth) {
var match = true;
currentPermalinkParts = currentPermalink.split('/');
expectedPermalinkParts = expectedPermalink.split('/');
for(var i = 0; i <= depth; i++) {
if (expectedPermalinkParts[i] !== currentPermalinkParts[i]) {
match = false;
}
}
if (match) {
return 'active';
}
}
);
module.exports = Metalsmith(__dirname)
.use(ignore('**/.DS_Store'))
.use(markdown())
.use(templates('handlebars'))
.use(imagemin({
optimizationLevel: 3,
svgoPlugins: [{ removeViewBox: false }]
}))
.use(sass({
outputStyle: 'compressed'
}))
.destination('./docs');