-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
71 lines (67 loc) · 1.96 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
const metalsmith = require('metalsmith');
const drafts = require('metalsmith-drafts');
const markdown = require('metalsmith-markdown');
const headingsidentifier = require('metalsmith-headings-identifier');
const collections = require('metalsmith-collections');
const permalinks = require('metalsmith-permalinks');
const layouts = require('metalsmith-layouts');
const sitemap = require('metalsmith-sitemap');
const Handlebars = require('handlebars');
const moment = require('moment');
Handlebars.registerHelper('is', function (value, test, options) {
if (value === test) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
Handlebars.registerHelper('date', function (date) {
return moment(date, "MM-DD-YYYY").format('Do MMM \'YY');
});
metalsmith(__dirname)
.metadata({
site: {
name: 'My site',
description: "My super sweet Metalsmith site on Netlify.",
generatorname: "Metalsmith",
generatorurl: "http://metalsmith.io/",
generatortitle: "Check out Metalsmith!",
hostname: "Netlify",
hosturl: "https://netlify.com/",
hosttitle: "Learn more about Netlify"
}
})
.source('./src')
.destination('./dist')
.clean(true)
.use(drafts())
.use(collections({
notes: {
pattern: 'notes/*.md',
sortBy: 'date',
reverse: true
},
projects: {
pattern: 'projects/*.md',
sortBy: 'date',
reverse: true
}
}))
.use(markdown())
.use(headingsidentifier())
.use(permalinks({
relative: false,
pattern: ':permalink'
}))
.use(layouts({
engine: 'handlebars',
directory: 'layouts',
default: 'default.hbs',
partials: 'layouts/partials'
}))
.use(sitemap({
hostname: "https://jinesh.org"
}))
.build(function (err) {
if (err) throw err;
});