refactor: ♻️ move options for markdown-it to reusable constant
This commit is contained in:
parent
e11fe0c683
commit
2899aa90de
1 changed files with 4 additions and 1 deletions
|
@ -22,6 +22,8 @@ import markdownItDeflist from 'markdown-it-deflist';
|
||||||
import markdownItFootnote from 'markdown-it-footnote';
|
import markdownItFootnote from 'markdown-it-footnote';
|
||||||
import markdownItImageFigures from 'markdown-it-image-figures';
|
import markdownItImageFigures from 'markdown-it-image-figures';
|
||||||
|
|
||||||
|
const MARKDOWNIT_OPTIONS = { html: true, linkify: true, typographer: true };
|
||||||
|
|
||||||
export default async function (eleventyConfig) {
|
export default async function (eleventyConfig) {
|
||||||
eleventyConfig.addPassthroughCopy('./src/css/prism.css');
|
eleventyConfig.addPassthroughCopy('./src/css/prism.css');
|
||||||
eleventyConfig.addWatchTarget('./src/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) =>
|
eleventyConfig.amendLibrary('md', (mdLib) =>
|
||||||
mdLib
|
mdLib
|
||||||
|
@ -141,6 +143,7 @@ export default async function (eleventyConfig) {
|
||||||
eleventyConfig.addFilter('readableDate', (dateObj) =>
|
eleventyConfig.addFilter('readableDate', (dateObj) =>
|
||||||
dateObj.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })
|
dateObj.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })
|
||||||
);
|
);
|
||||||
|
eleventyConfig.addFilter('toHTML', (str) => new markdownIt(MARKDOWNIT_OPTIONS).render(str ? str : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue