-
Notifications
You must be signed in to change notification settings - Fork 7
/
metalsmith.js
57 lines (52 loc) · 1.25 KB
/
metalsmith.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
const fs = require("fs");
const Metalsmith = require('metalsmith');
const watch = require('metalsmith-watch');
const pug = require('metalsmith-pug/lib/node6');
const sass = require('metalsmith-sass');
const metalsmithPrism = require('metalsmith-prism');
const markdown = require("jstransformer-markdown-it");
const marked = require("marked");
const yaml = require("js-yaml");
marked.setOptions({
langPrefix: 'language-'
});
function loadYamlDoc(path) {
try {
return yaml.safeLoad(fs.readFileSync(`./docs/${path}.yaml`, 'utf8'));
} catch(e) {
console.log(e);
throw e;
}
}
const abstractions = [
"semigroup", "monoid",
"functor", "applicative", "monad",
"foldable", "traversable"
].map(loadYamlDoc);
const implementations = [
"maybe", "either", "cons", "infinitelist", "writer"
].map(loadYamlDoc);
Metalsmith(__dirname)
.source('./docs')
.destination('./docs-build')
.use(pug({
pretty: true,
filters: {markdown},
locals: {
abstractions, implementations, marked
}
}))
.use(metalsmithPrism())
.use(sass({
outputStyle: "expanded"
}))
.use(watch({
paths: {
"${source}/**/*": true,
"**/*.pug": "**/*.pug"
},
livereload: true
}))
.build(function(err) {
if (err) throw err;
});