-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
73 lines (71 loc) · 2.11 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
const metalsmith = require("metalsmith");
const markdown = require("metalsmith-markdown");
const layouts = require("metalsmith-layouts");
const collections = require("metalsmith-collections");
const permalinks = require("metalsmith-permalinks");
const assets = require('metalsmith-assets');
const sitemap = require('metalsmith-sitemap');
const pagination = require('metalsmith-pagination');
const nunjucks = require("nunjucks");
const moment = require("moment");
// handlebars.registerHelper("formatTime", (date, format) => {
// return moment(date).format(format);
// });
metalsmith(__dirname)
.metadata({
site: {
name: "Metalplate",
description: "A Metalsmith boilerplate for blogs."
}
})
.source("./src")
.destination("./public")
.clean(true)
.use(collections({
articles: {
pattern: "articles/**/*.md",
sortBy: "date",
reverse: true
},
}))
.use(markdown())
.use(pagination({
'collections.articles': {
perPage: 2,
layout: 'index.html',
first: 'index.html',
path: 'page/:num/index.html',
}
}))
.use(permalinks({
relative: false,
pattern: ':title',
// each linkset defines a match, and any other desired option
linksets: [{
match: { collection: 'articles' },
pattern: 'blog/:title',
}]
}))
.use(assets({
source: './src/assets/css', // relative to the working directory
destination: './assets/css' // relative to the build directory
}))
.use(layouts({
engine: "nunjucks",
directory: "./layouts",
default: "article.html",
pattern: ["*/*/*.html", "*/*.html", "*.html"],
partials: "./layouts/partials"
}))
.use(sitemap({
"hostname": "https://www.example.com",
"pattern": ["**/*.html","!page/**"],
"omitIndex": true
}))
.build((err) => {
if (err) {
console.log(err);
} else {
console.log("Successfully forged boilerplate!");
}
});