-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js
74 lines (70 loc) · 1.93 KB
/
common.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
67
68
69
70
71
72
73
74
/* global: module */
var Metalsmith = require('metalsmith'),
_ = require('lodash'),
Q = require('q'),
assets = require('metalsmith-assets'),
bower = require('bower'),
layouts = require('metalsmith-layouts'),
markdown = require('metalsmith-markdown'),
moment = require('moment'),
permalinks = require('metalsmith-permalinks'),
wordcount = require('metalsmith-word-count');
var metadata = {
"title": "DIT4C",
"description": "Data Intensive Tools for the Cloud"
};
var bowerPlugin = function (files, metalsmith, done) {
bower.commands
.install()
.on('end', function () {
bower.commands
.list()
.on('end', function (output) {
var libs = (function(data) {
var deps = function(m, data) {
return _.reduce(data.dependencies, function(m, v, k) {
return deps(_.set(m, k, v.canonicalDir), v);
}, m);
};
return deps({}, data);
})(output);
_.reduce(libs, function(m, v, k) {
return m.then(function() {
var d = Q.defer();
(assets({
source: v,
destination: './libs/'+k
}))(files, metalsmith, function() { d.resolve(); });
return d.promise;
});
}, Q('')).done(function() { done(); });
});
});
};
var timestamp = function (files, metalsmith, done) {
for (var f in files) {
var data = files[f];
data['timestamp'] = moment.utc(data.stats.mtime).format();
}
done();
};
module.exports =
Metalsmith(__dirname)
.frontmatter(true)
.metadata(metadata)
.clean(true)
.use(markdown())
.use(timestamp)
.use(layouts({
"engine": "hogan",
"rename": true
}))
.use(wordcount())
.use(permalinks({
"pattern": ":title"
}))
.use(assets({
source: './assets',
destination: '.'
}))
.use(bowerPlugin);