-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
75 lines (72 loc) · 1.95 KB
/
index.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
const Metalsmith = require('metalsmith');
const layouts = require('metalsmith-layouts');
const markdown = require('metalsmith-markdown');
const sass = require('metalsmith-sass');
const collections = require('metalsmith-collections');
const inPlace = require('metalsmith-in-place');
const permalinks = require('metalsmith-permalinks');
const pagination = require('metalsmith-pagination');
const Handlebars = require('handlebars');
const {fetchMeetupDetails} = require('./meetup');
const handlebarsHelpers = require('./handlebarsHelpers');
Object.keys(handlebarsHelpers).forEach(name => Handlebars.registerHelper(name, handlebarsHelpers[name]))
async function build() {
const meetupDetails = await fetchMeetupDetails();
Metalsmith(__dirname)
.metadata({
site : {
title: 'JSOxford',
url: 'https://jsoxford.com',
description: 'A regular meetup of JavaScript enthusiasts every other month in Oxford, UK.'
},
meetup: meetupDetails
})
.source('./src')
.destination('./build')
.clean(true)
.use(collections({
events: {
pattern: '{events,posts}/*',
sortBy: 'date',
reverse: true,
},
pages: {
pattern: 'pages/*'
}
}))
.use(pagination({
'collections.events': {
perPage: 5,
layout: 'archive.html',
first: 'archive/index.html',
path: 'archive/:num/index.html',
pageMetadata: {
title: 'Archive'
}
}
}))
.use(inPlace({
engine: 'handlebars',
partials: 'layouts/partials'
}))
.use(markdown())
.use(permalinks({
pattern: ':date-:title',
date: 'YYYY-MM-DD',
linksets: [
{
match: { collection: 'pages' },
pattern: ':title'
}
]
}))
.use(layouts({
engine: 'handlebars',
partials: 'layouts/partials'
}))
.use(sass())
.build(function(err) {
if (err) throw err;
});
}
build();