-
Notifications
You must be signed in to change notification settings - Fork 1
/
metalsmith.js
82 lines (68 loc) · 1.76 KB
/
metalsmith.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
'use strict';
var metalsmith = require('metalsmith');
var drafts = require('metalsmith-drafts');
var markdown = require('metalsmith-markdown');
var permalinks = require('metalsmith-permalinks');
var templates = require('metalsmith-templates');
var excerpts = require('metalsmith-excerpts');
var collections = require('metalsmith-collections');
var feed = require('metalsmith-feed');
var pagination = require('metalsmith-pagination');
var assets = require('metalsmith-assets');
var sass = require('metalsmith-sass');
var autoprefixer = require('metalsmith-autoprefixer');
var uglify = require('metalsmith-uglify');
var imagemin = require('metalsmith-imagemin');
function build (cb) {
return metalsmith(__dirname)
// core
.source('posts')
.destination('_build')
.metadata({
site: {
title: 'My Blog',
url: 'http://my-url.sk',
author: 'John Doe'
}
})
// html
.use(drafts())
.use(markdown())
.use(permalinks(':title'))
.use(excerpts())
// pagination
.use(collections())
.use(feed({collection: 'articles'}))
.use(pagination({
'collections.articles': {
perPage: 2,
template: 'loop.html',
first: 'index.html',
path: 'archive/:num/index.html',
pageMetadata: {
title: 'Archive'
}
}
}))
// templates
.use(templates({
engine: 'swig',
directory: 'layouts'
}))
// assets
.use(assets({
source: './assets/',
destination: './'
}))
// css
.use(sass({
includePaths: ['./assets/css']
}))
.use(autoprefixer())
// js
.use(uglify())
// images
.use(imagemin())
.build(cb);
}
module.exports = build;