diff --git a/eleventy.config.js b/eleventy.config.js index e3f4645..579d83b 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -22,6 +22,8 @@ import markdownItDeflist from 'markdown-it-deflist'; import markdownItFootnote from 'markdown-it-footnote'; import markdownItImageFigures from 'markdown-it-image-figures'; +const MARKDOWNIT_OPTIONS = { html: true, linkify: true, typographer: true }; + export default async function (eleventyConfig) { eleventyConfig.addPassthroughCopy('./src/css/prism.css'); eleventyConfig.addWatchTarget('./src/css/'); @@ -104,7 +106,7 @@ export default async function (eleventyConfig) { } }); - eleventyConfig.setLibrary('md', markdownIt({ html: true, linkify: true, typographer: true })); + eleventyConfig.setLibrary('md', markdownIt(MARKDOWNIT_OPTIONS)); eleventyConfig.amendLibrary('md', (mdLib) => mdLib @@ -141,6 +143,7 @@ export default async function (eleventyConfig) { eleventyConfig.addFilter('readableDate', (dateObj) => dateObj.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }) ); + eleventyConfig.addFilter('toHTML', (str) => new markdownIt(MARKDOWNIT_OPTIONS).render(str ? str : '')); } export const config = {