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
|
const toml = require('@iarna/toml')
const markdown = require("markdown-it")
const eleventyNavigation = require('@11ty/eleventy-navigation')
const eleventyRss = require('@11ty/eleventy-plugin-rss')
const MD_OPTIONS = {
html: true,
};
filter_local_date = function(date) {
// yyyy-MM-dd
return date.getFullYear() + '-'
+ (date.getMonth() + 1).toString().padStart(2, '0') + '-'
+ date.getDate().toString().padStart(2, '0')
}
filter_rfc3339_datetime = function(date) {
// yyyy-MM-dd HH:mm:ssXXX
date.setSeconds(0, 0)
return date.toISOString().replace('T', ' ');
}
module.exports = function(eleventyConfig) {
eleventyConfig.setLibrary('md', markdown(MD_OPTIONS));
eleventyConfig.addPlugin(eleventyNavigation)
eleventyConfig.addPlugin(eleventyRss)
eleventyConfig.addPassthroughCopy('./css/')
eleventyConfig.addPassthroughCopy('./img/')
eleventyConfig.addPassthroughCopy('./files/')
eleventyConfig.addFilter('local_date', filter_local_date)
eleventyConfig.addFilter('rfc3339_datetime', filter_rfc3339_datetime)
eleventyConfig.addFilter('md', str => {
return markdown(MD_OPTIONS).render(str);
})
eleventyConfig.setFrontMatterParsingOptions({
engines: {
toml: toml.parse.bind(toml)
},
language: 'toml',
excerpt: true
})
// skip drafts
eleventyConfig.addGlobalData('eleventyComputed.permalink', function() { return (data) => {
return data.draft && !process.env.BUILD_DRAFTS ? false : data.permalink
}})
eleventyConfig.addGlobalData('eleventyComputed.eleventyExcludeFromCollections', function() { return (data) => {
return data.draft && !process.env.BUILD_DRAFTS ? false : data.eleventyExcludeFromCollections
}})
eleventyConfig.on('eleventy.before', ({runMode}) => {
if(runMode === 'serve' || runMode === 'watch') {
process.env.BUILD_DRAFTS = true
}
})
return {
dir: {
input: 'src',
includes: '../_includes',
data: '../_data',
output: '_site'
}
}
}
|