-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eleventy.js
90 lines (79 loc) · 2.85 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
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
const { DateTime } = require('luxon');
const { EleventyRenderPlugin } = require('@11ty/eleventy');
const pluginBundle = require('@11ty/eleventy-plugin-bundle');
const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
const { attrs } = require('@mdit/plugin-attrs');
const { figure } = require('@mdit/plugin-figure');
const { imgSize } = require('@mdit/plugin-img-size');
const { tab } = require('@mdit/plugin-tab');
const embedYouTube = require('eleventy-plugin-youtube-embed');
const markdownItCheckbox = require('markdown-it-task-checkbox');
const markdownItCallout = require('./eleventy.callout');
const markdownItLinkPreview = require('./eleventy.linkPreview');
module.exports = function (eleventyConfig) {
/* Plugins */
eleventyConfig.addPlugin(EleventyRenderPlugin);
eleventyConfig.addPlugin(pluginBundle);
eleventyConfig.addPlugin(syntaxHighlight, {
// alwaysWrapLineHighlights: true,
});
eleventyConfig.amendLibrary('md', (mdLib) =>
mdLib.use(markdownItCheckbox, {
ulClass: 'checkbox-list',
liClass: 'checkbox-list-item',
}),
);
eleventyConfig.amendLibrary('md', (mdLib) => mdLib.use(markdownItCallout));
eleventyConfig.amendLibrary('md', (mdLib) => mdLib.use(attrs));
eleventyConfig.amendLibrary('md', (mdLib) => mdLib.use(figure));
eleventyConfig.amendLibrary('md', (mdLib) => mdLib.use(imgSize));
eleventyConfig.amendLibrary('md', (mdLib) => mdLib.use(tab));
eleventyConfig.amendLibrary('md', (mdLib) =>
mdLib.use(markdownItLinkPreview),
);
eleventyConfig.addPlugin(embedYouTube, {
embedClass: 'youtube-embed',
});
/* Public Asset */
eleventyConfig.addPassthroughCopy({
'./public/': '/',
});
/* Post Date */
eleventyConfig.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd');
});
eleventyConfig.addFilter('filterTagList', function filterTagList(tags) {
const t = (tags || []).filter(
(tag) => !['all', 'nav', 'post', 'posts', 'docs'].includes(tag),
);
return t;
});
eleventyConfig.addFilter('isEmpty', function isEmptyList(tags) {
const t = (tags || []).filter(
(tag) => !['all', 'nav', 'post', 'posts', 'docs'].includes(tag),
);
return t.length > 0 ? true : false;
});
eleventyConfig.addGlobalData('eleventyComputed.permalink', function () {
return (data) => {
if (data.draft && !process.env.BUILD_DRAFTS) {
return false;
}
return data.permalink;
};
});
eleventyConfig.on('eleventy.before', ({ runMode }) => {
if (runMode === 'serve' || runMode === 'watch') {
process.env.BUILD_DRAFTS = true;
}
});
return {
dir: {
input: 'content', // default: "."
includes: '../src/includes', // default: "_includes"
data: '../src/data', // default: "_data"
output: 'dist',
},
pathPrefix: '/',
};
};