-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.js
51 lines (48 loc) · 1.2 KB
/
build.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
const Metalsmith = require('metalsmith');
const markdown = require('metalsmith-markdown');
const layouts = require('metalsmith-layouts');
const autotoc = require('metalsmith-autotoc');
function exclude() {
return function(files, metalsmith, done) {
for (let file in files) {
if (/^\.gitignore|\.circleci/.test(file)) {
delete files[file];
}
}
done();
}
}
function modifyDocsPath() {
return function(files, metalsmith, done) {
for (let file in files) {
if (/^docs\//.test(file)) {
if (/\.md$/.test(file)) {
files[file.replace('docs/', '')] = files[file];
}
delete files[file];
}
}
done();
}
}
Metalsmith(__dirname)
.source('src')
.destination('dist')
.clean(true)
.metadata({
title: 'TypeDB OSI'
})
.use(exclude())
.use(modifyDocsPath())
.use(markdown())
.use(autotoc({
selector: 'h2',
}))
.use(layouts({
directory: 'layouts',
pattern: '*.html',
suppressNoFilesError: true,
}))
.build(function(err) {
if (err) throw err;
});