From 711dcbab53d002a0689bc8d343650d3cee7f2b6f Mon Sep 17 00:00:00 2001 From: Neil Brommer Date: Fri, 20 Oct 2023 09:48:24 -0700 Subject: [PATCH] Allow markdown in post descriptions --- eleventy.config.js | 4 ++++ src/_includes/posts-list.njk | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/eleventy.config.js b/eleventy.config.js index 5bce407..68d33b1 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -7,6 +7,7 @@ const mdDefList = require("markdown-it-deflist"); const mdToc = require("markdown-it-table-of-contents"); const mdAnchor = require("markdown-it-anchor"); const nunjucksDate = require("nunjucks-date"); +const markdownIt = require("markdown-it"); function addEleventyPlugins(eleventyConfig) { eleventyConfig.addPlugin(eleventyNavigationPlugin); @@ -30,6 +31,9 @@ function configureMarkdown(eleventyConfig) { } function addFilters(eleventyConfig) { + let md = new markdownIt(); + + eleventyConfig.addFilter("renderMarkdown", (mdString) => md.render(mdString)); eleventyConfig.addFilter("log", (value) => console.log(value)); eleventyConfig.addFilter("date", nunjucksDate); eleventyConfig.addFilter("IsNotPage", (collection, url) => diff --git a/src/_includes/posts-list.njk b/src/_includes/posts-list.njk index 40df637..891dd50 100644 --- a/src/_includes/posts-list.njk +++ b/src/_includes/posts-list.njk @@ -29,7 +29,7 @@ {% endfor %} -

{{ post.data.description }}

+

{{ post.data.description | renderMarkdown | safe }}

{% endfor %} {% else %}