refactor: ♻️ move options for markdown-it to reusable constant

This commit is contained in:
Sebin Nyshkim 2025-03-16 18:57:07 +01:00
parent e11fe0c683
commit 2899aa90de

View file

@ -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 = {