forked from sparkbox/trivia11y
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.eleventy.js
More file actions
28 lines (23 loc) · 733 Bytes
/
Copy path.eleventy.js
File metadata and controls
28 lines (23 loc) · 733 Bytes
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
const { marked } = require('marked');
const DOMPurify = require('isomorphic-dompurify');
const markdownToHtml = (markdown) => {
const html = marked.parse(markdown.replace(/\\/g, ''), {
breaks: true,
});
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);
return {
dir: {
input: 'pages',
output: 'dist',
includes: '../src',
},
markdownTemplateEngine: 'njk',
};
};