-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.js
executable file
·110 lines (100 loc) · 2.3 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var Metalsmith = require("metalsmith");
var markdown = require("metalsmith-markdown");
var asciidoctor = require("metalsmith-asciidoctor");
var less = require("metalsmith-less");
var ignore = require("metalsmith-ignore");
var assets = require("metalsmith-static");
var excerpts = require('metalsmith-better-excerpts');
var news = require('./lib/metalsmith/news');
var handlebars = require('./lib/metalsmith/handlebars');
var argv = require("yargs").argv;
var versions = require("./conf/versions.json");
var helpers = require("./lib/helpers");
// basic Metalsmith setup
var metalsmith = Metalsmith(__dirname)
.metadata({
versions: versions
})
.source('./src')
.destination('./build')
.clean(true);
/*
* Transform Markdown files to HTML
*/
metalsmith.use(markdown({
// optional marked options
}));
/*
* Transform Asciidoc files to HTML
*/
metalsmith.use(asciidoctor({
pattern: "**/*.adoc",
options: {
attributes: {
"icons": "font"
}
}
}));
/*
* Adds a 'excerpt' property to all pages. This will be used
* to display excerpts for the news entries.
*/
metalsmith.use(excerpts({
pruneLength: 100
}));
/*
* This will process all the news entries in the 'news' directory,
* extract the date from the file name, create a pretty URL for them
* and create two collections 'news.all' and 'news.latest' ordered
* by the entry date
*/
metalsmith.use(news({
pattern: "news/20*.html",
collection: "news",
latestCount: 3
}));
/*
* Apply template to get a full HTML page. You can choose which
* template to use using the "template" header property.
*/
metalsmith.use(handlebars({
pattern: "**/*.html",
directory: "_templates",
helpers: helpers
}));
/*
* Transform *.less files to *.css
*/
metalsmith.use(less({
"pattern": "css/style.less"
}));
/*
* There are some files in the "src" folder which we don't need in
* the file site.
*/
metalsmith.use(ignore([
"**/*.less",
"_templates/**"
]));
/*
* Copy assets which shouldn't be processed by the pipeline. This
* is useful for including stuff from "node_modules" in the site.
*/
metalsmith.use(assets([
{
"src": "assets",
"dest": "."
},
{
"src": "node_modules/font-awesome/fonts",
"dest": "fonts"
}
]));
/*
* Run the build
*/
metalsmith.build(function (err) {
if (err) {
throw err;
}
});