generated from dustin-jw/eleventy-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eleventy.config.js
55 lines (49 loc) · 1.46 KB
/
eleventy.config.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
import hljs from 'highlight.js';
import markdownIt from 'markdown-it';
import markdownItAnchor from 'markdown-it-anchor';
import pluginRSS from '@11ty/eleventy-plugin-rss';
export default function(eleventyConfig) {
eleventyConfig.addPassthroughCopy({ 'src/public': '/' });
const markdownOptions = {
html: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return `<pre tabindex="0" role="region" aria-label="Code sample"><code class="language-${lang}">${
hljs.highlight(str, {
language: lang,
ignoreIllegals: true,
}).value
}</code></pre>`;
} catch {
// swallow error, fall through to default case
}
}
return `<pre tabindex="0" role="region" aria-label="Code sample"><code>${markdownIt.utils.escapeHtml(str)}</code></pre>`;
},
};
const md = markdownIt(markdownOptions).use(markdownItAnchor, {
level: 2,
permalink: markdownItAnchor.permalink.linkInsideHeader({
class: 'cmp-permalink__link',
renderAttrs: (slug) => ({ 'aria-labelledby': slug }),
symbol: '<span aria-hidden="true">#</span>',
placement: 'after',
}),
});
eleventyConfig.setLibrary('md', md);
eleventyConfig.addLayoutAlias('default', 'partials/layout.njk');
eleventyConfig.addPlugin(pluginRSS, {
posthtmlRenderOptions: {
closingSingleTag: 'default',
},
});
};
export const config = {
dir: {
input: 'pages',
output: 'dist',
includes: '../src',
},
markdownTemplateEngine: 'njk',
};