generated from dustin-jw/eleventy-starter-lite
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eleventy.js
32 lines (27 loc) · 869 Bytes
/
.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
const { marked } = require('marked');
const DOMPurify = require('isomorphic-dompurify');
const markdownToHtml = (markdown) => {
const html = marked.parse(markdown.replace(/\\/g, ''), {
breaks: true,
mangle: false,
headerIds: false,
headerPrefix: false,
});
const withKbdElements = html.replace(/\[\[(.+?)\]\]/g, '<kbd>$1</kbd>');
const cleanHtml = DOMPurify.sanitize(withKbdElements);
return cleanHtml;
};
module.exports = function (eleventyConfig) {
eleventyConfig.addPassthroughCopy({ 'src/public/': '/' });
eleventyConfig.addLayoutAlias('default', 'layout.njk');
eleventyConfig.addFilter('mdToHtml', markdownToHtml);
eleventyConfig.addFilter('csvList', (values) => values.join(', '));
return {
dir: {
input: 'pages',
output: 'dist',
includes: '../src',
},
markdownTemplateEngine: 'njk',
};
};