-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheleventy.config.js
67 lines (60 loc) · 1.66 KB
/
eleventy.config.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
const markdownIt = require('markdown-it')
const htmlmin = require('html-minifier-terser')
const compression = require('compression')
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy({
'./node_modules/alpinejs/dist/cdn.min.js': './main.min.js',
})
eleventyConfig.addPassthroughCopy('./src/assets/images/*')
eleventyConfig.addPassthroughCopy('./src/assets/fonts/*')
eleventyConfig.addWatchTarget('./src/assets/main.css')
eleventyConfig.setDataDeepMerge(true)
eleventyConfig.addFilter('markdown', function (value) {
return new markdownIt({
html: true,
typographer: true,
quotes: '«»',
}).render(value)
})
eleventyConfig.addFilter('markdownInline', function (value) {
return new markdownIt({
html: false,
}).renderInline(value)
})
eleventyConfig.addTransform('htmlmin', function (content, outputPath) {
if (outputPath && outputPath.endsWith('.html')) {
let minified = htmlmin.minify(content, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
minifyCSS: {
level: 2,
},
})
return minified
}
return content
})
eleventyConfig.setServerOptions({
enabled: true,
showVersion: true,
port: 8888,
middleware: [
// function compression(req, res, next) {
// res.writeHead(200, { "content-type": "text/html" });
// res.end();
// next();
// },
],
})
return {
markdownTemplateEngine: 'njk',
templateFormats: ['njk', 'md'],
dir: {
input: 'src',
data: '_data',
includes: '_includes',
output: 'dist',
},
}
}