-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
101 lines (94 loc) · 2.62 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
'use strict';
var Metalsmith = require('metalsmith'),
markdown = require('metalsmith-markdown'),
layouts = require('metalsmith-layouts'),
define = require('metalsmith-define'),
permalinks = require('metalsmith-permalinks'),
css = require('metalsmith-clean-css'),
fingerprint= require('metalsmith-fingerprint'),
inPlace = require('metalsmith-in-place'),
multiLanguage = require('metalsmith-multi-language'),
i18n = require('metalsmith-i18n'),
collections = require('metalsmith-collections'),
highlighter = require('highlighter');
const DEFAULT_LOCALE = 'en';
const LOCALES = ['fr', 'en'];
Metalsmith(__dirname)
.source('src')
.destination('dist')
.use(define({
Site: {
url: '',
title: 'Charles-Henri Decultot',
description: 'Freelance Web-Developer and Enterprise Software Passionate'
},
googleAnalytics: '',
owner: {
url: '',
name: ''
},
moment: require('moment')
}))
.use(collections({
'content_en': 'content/*_en.md',
'content_fr': 'content/*_fr.md',
'articles_en': {
pattern: 'articles/**/*_en.md',
sortBy: 'date',
reverse: true
},
'articles_fr': {
pattern: 'articles/**/*_fr.md',
sortBy: 'date',
reverse: true
}
}))
.use(multiLanguage({
default: DEFAULT_LOCALE,
locales: LOCALES
}))
.use(i18n({
default: DEFAULT_LOCALE,
locales: LOCALES,
directory: 'locales'
}))
.use(markdown({
"gfm": true,
"breaks": true,
"tables": true,
highlight: highlighter()
}))
.use(permalinks({
relative: false,
pattern: ':locale/:title/',
linksets: [{
match: { collection: 'content_en' },
pattern: ':locale/content/:title/'
}, {
match: { collection: 'content_fr' },
pattern: ':locale/content/:title/'
}, {
match: { collection: 'articles_en' },
pattern: ':locale/articles/:title/'
}, {
match: { collection: 'articles_fr' },
pattern: ':locale/articles/:title/'
}]
}))
.use(css({
files:"styles/**/*.css",
cleanCSS: {
rebase: true
}
}))
.use(layouts({
engine: 'jade',
directory: 'templates',
pattern: '**/*.html'
}))
.build(function (err) {
if(err) {
console.log(err)
}
console.log('Build Completed!')
})