firefish-archive/config/plugins/markdown.js

25 lines
639 B
JavaScript
Raw Normal View History

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);
eleventyConfig.addFilter('md', content => content ? markdownLib.render(content) : "");
2024-01-05 11:53:44 +00:00
}