2024-01-05 11:53:44 +00:00
|
|
|
const markdownIt = require('markdown-it');
|
|
|
|
const markdownItLinkAttributes = require('markdown-it-link-attributes');
|
|
|
|
|
|
|
|
const markdownLib = markdownIt({
|
|
|
|
html: true,
|
|
|
|
breaks: true,
|
|
|
|
linkify: true,
|
|
|
|
typographer: true
|
|
|
|
}).use(markdownItLinkAttributes, [
|
|
|
|
{
|
|
|
|
// match external links
|
|
|
|
matcher(href) {
|
|
|
|
return href.match(/^https?:\/\//);
|
|
|
|
},
|
|
|
|
attrs: {
|
|
|
|
target: '_blank',
|
|
|
|
rel: 'noreferrer noopener'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
|
|
|
|
module.exports = function (eleventyConfig) {
|
|
|
|
eleventyConfig.setLibrary('md', markdownLib);
|
2024-01-05 13:36:37 +00:00
|
|
|
eleventyConfig.addFilter('md', content => content ? markdownLib.render(content) : "");
|
2024-01-05 11:53:44 +00:00
|
|
|
}
|