This repository was archived by the owner on Jan 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathindex.js
93 lines (88 loc) · 2.52 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
'use strict';
const path = require('path');
const metalsmith = require('metalsmith');
const markdown = require('metalsmith-markdown');
const assets = require('metalsmith-assets');
const layouts = require('metalsmith-layouts');
const multiLanguage = require('metalsmith-multi-language');
const permalinks = require('metalsmith-permalinks');
const collections = require('metalsmith-collections');
const rewrite = require('metalsmith-rewrite');
const slug = require('metalsmith-slug');
const relative = require('metalsmith-relative');
const prefixoid = require('metalsmith-prefixoid');
const argv = require('minimist')(process.argv.slice(2));
const DEFAULT_LOCALE = 'en';
const LOCALES = ['en', 'es'];
metalsmith(__dirname)
.source('src/content')
.use(collections({
'platformer_en': {
pattern: 'platformer/*_en.md',
sortBy: 'path'
},
'platformer_es': {
pattern: 'platformer/*_es.md',
sortBy: 'path'
},
'setup_en': {
pattern: 'setup/*_en.md',
sortBy: 'path'
},
'bonus': {
pattern: 'bonus/*.md'
},
'coach_en' :{
pattern: 'coach-guide/*.md'
}
}))
.use(multiLanguage({
locales: LOCALES,
default: DEFAULT_LOCALE
}))
.use(slug())
.use(markdown())
.use(permalinks({
relative: false,
pattern: ':locale/:slug/',
linksets: [{
match: { collection: 'platformer_en' },
pattern: ':locale/guides/platformer/:slug'
}, {
match: { collection: 'platformer_es' },
pattern: ':locale/guias/plataformas/:slug'
}, {
match: { collection: 'setup_en' },
pattern: ':locale/guides/setup/:slug'
}, {
match: { collection: 'bonus' },
pattern: ':locale/bonus/:slug'
}, {
match: { collection: 'coach_en'},
pattern: ':locale/guides/coach'
}]
}))
.use(relative())
.use(layouts({
engine: 'pug',
default: 'default.pug',
pattern: '**/*.html',
directory: 'src/layouts',
cache: false,
pretty: true
}))
.use(assets({source: 'src/assets'}))
.use(prefixoid({
prefix: argv.base || '',
tag: 'a',
attr: 'href'
}))
.use(prefixoid({
prefix: argv.base || '',
tag: 'img',
attr: 'src'
}))
.destination('dist')
.build(function (err) {
if (err) { console.error(err); }
});