-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
63 lines (54 loc) · 1.61 KB
/
.eleventy.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
const rssPlugin = require('@11ty/eleventy-plugin-rss');
const markdownIt = require('markdown-it');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
module.exports = function(config) {
config.addPlugin(rssPlugin);
config.addPlugin(syntaxHighlight);
config.addPassthroughCopy({ 'src/images': 'images' });
config.addPassthroughCopy({ "src/**/*.png": `images/posts` });
config.addPassthroughCopy('src/CNAME');
const md = markdownIt();
const defaultRender = md.renderer.rules?.link_open || function(tokens, idx, options, env, self) {
return self.renderToken(tokens, idx, options);
};
md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
const aIndex = tokens[idx].attrIndex('target');
if (aIndex < 0) {
tokens[idx].attrPush(['target', '_blank']);
} else {
tokens[idx].attrs[aIndex][1] = '_blank';
}
return defaultRender(tokens, idx, options, env, self);
};
config.setLibrary('md', md);
config.addFilter('readableDate', (value) => {
return value.toLocaleString('en', {
year: 'numeric',
month: 'long',
day: 'numeric',
});
});
config.addFilter('pageTags', (tags) => {
const generalTags = ['post', 'posts'];
return tags
.toString()
.split(',')
.filter((tag) => {
return !generalTags.includes(tag);
});
});
return {
dir: {
input: 'src',
output: 'public',
layouts: 'layouts',
includes: 'layouts/includes',
data: 'data',
},
passthroughFileCopy: true,
templateFormats: [
'md',
'njk',
],
};
}