-
Notifications
You must be signed in to change notification settings - Fork 1
/
hoast.js
95 lines (85 loc) · 2.28 KB
/
hoast.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
import Hoast from '@hoast/hoast'
import ProcessFrontmatter from '@hoast/process-frontmatter'
import ProcessMarkdown from '@hoast/process-markdown'
import ProcessMithril from '@hoast/process-mithril'
import ProcessPostprocess from '@hoast/process-postprocess'
import ProcessWritefiles from '@hoast/process-writefiles'
import SourceReadfiles from '@hoast/source-readfiles'
const hoast = new Hoast()
.addCollections([
// Add pages collection.
{
// Read files from pages directory.
source: new SourceReadfiles({
directory: 'src/pages',
}),
processes: [
// Extract frontmatter.
new ProcessFrontmatter(),
// Convert markdown to HTML.
new ProcessMarkdown({
highlightOptions: {},
remarkPlugins: [
'remark-external-links',
],
}),
// Template using mithril.
new ProcessMithril({
componentDirectory: 'src/components',
componentPath: 'html.js',
prefix: '<!DOCTYPE html>',
}),
// Bundle and minify.
new ProcessPostprocess({
minify: process.env.NODE_ENV === 'production',
cssPlugins: [
'postcss-import',
'autoprefixer',
'postcss-preset-env',
],
}),
// Write to filesystem.
new ProcessWritefiles({
directory: '../docs',
}),
],
},
// Add style sheets collection.
{
source: new SourceReadfiles({
directory: 'src/styles',
}),
processes: [
new ProcessPostprocess({
mode: 'css',
minify: process.env.NODE_ENV === 'production',
cssPlugins: [
'postcss-import',
'autoprefixer',
'postcss-preset-env',
],
}),
new ProcessWritefiles({
directory: '../docs/styles',
}),
],
},
// Transfer files from .assets directory over.
{
source: new SourceReadfiles({
directory: 'src/assets',
readOptions: {
encoding: null,
},
}),
processes: [
new ProcessWritefiles({
directory: '../docs/assets',
writeOptions: {
encoding: null,
},
}),
],
},
])
export default hoast