diff --git a/_includes/recipe.njk b/_includes/recipe.njk
index 7c80d1e..e4c379f 100644
--- a/_includes/recipe.njk
+++ b/_includes/recipe.njk
@@ -30,7 +30,7 @@ pageType: recipe
- {{ content | safe }}
+ {{ content | renderRecipeMarkdown | safe }}
{% set recipeTags = page.inputPath | extractTagsFromFile %}
diff --git a/eleventy.config.js b/eleventy.config.js
index ea1f998..65f10ce 100644
--- a/eleventy.config.js
+++ b/eleventy.config.js
@@ -1,5 +1,5 @@
const markdownIt = require("markdown-it");
-const markdownItFootnote = require("markdown-it-footnote");
+const markdownItFootnoteCustom = require('./lib/footnotes/plugin');
const markdownItMermaid = require('markdown-it-mermaid').default
const markdownItTaskLists = require('markdown-it-task-lists');
const markdownItMeasurements = require('./lib/measurements/plugin');
@@ -18,12 +18,11 @@ const isReleased = (post) => {
}
const sharedPlugins = [
- markdownItFootnote,
+ markdownItFootnoteCustom,
markdownItHashtag,
markdownItMermaid,
[markdownItTaskLists, { enabled: true, label: true, labelAfter: false }],
markdownItDetails,
- markdownItMeasurements,
];
const applyPlugins = (md, plugins) =>
@@ -39,19 +38,7 @@ const createMarkdownInstance = (extraPlugins = []) => {
};
const md = createMarkdownInstance([markdownItStripTrailingHashtags]);
-
-// Customize footnote rendering to remove brackets
-md.renderer.rules.footnote_ref = (tokens, idx, options, env, slf) => {
- const id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
- const n = Number(tokens[idx].meta.id + 1).toString();
- let refid = id;
-
- if (tokens[idx].meta.subId > 0) {
- refid += ':' + tokens[idx].meta.subId;
- }
-
- return '';
-};
+const recipeMd = createMarkdownInstance([markdownItStripTrailingHashtags, markdownItMeasurements]);
const tagExtractorMd = createMarkdownInstance();
@@ -69,6 +56,11 @@ module.exports = (eleventyConfig) => {
}
});
+ eleventyConfig.addFilter("renderRecipeMarkdown", (content) => {
+ if (!content) return '';
+ return recipeMd.render(content);
+ });
+
eleventyConfig.setLibrary("md", md);
eleventyConfig.addFilter("dateTimeFormat", (date) => {
diff --git a/lib/footnotes/plugin.js b/lib/footnotes/plugin.js
new file mode 100644
index 0000000..15e078f
--- /dev/null
+++ b/lib/footnotes/plugin.js
@@ -0,0 +1,20 @@
+const markdownItFootnote = require("markdown-it-footnote");
+
+// Wraps markdown-it-footnote and customizes rendering to remove brackets
+const markdownItFootnoteCustom = (md) => {
+ md.use(markdownItFootnote);
+
+ md.renderer.rules.footnote_ref = (tokens, idx, options, env, slf) => {
+ const id = slf.rules.footnote_anchor_name(tokens, idx, options, env, slf);
+ const n = Number(tokens[idx].meta.id + 1).toString();
+ let refid = id;
+
+ if (tokens[idx].meta.subId > 0) {
+ refid += ':' + tokens[idx].meta.subId;
+ }
+
+ return '';
+ };
+};
+
+module.exports = markdownItFootnoteCustom;
\ No newline at end of file
diff --git a/recipe.njk b/recipe.njk
index 003b165..85d12eb 100644
--- a/recipe.njk
+++ b/recipe.njk
@@ -29,7 +29,7 @@ eleventyComputed:
- {{ recipe.content | safe }}
+ {{ recipe.content | renderRecipeMarkdown | safe }}
{% set recipeTags = recipe.inputPath | extractTagsFromFile %}
diff --git a/recipes/recipes.11tydata.js b/recipes/recipes.11tydata.js
index d0c658d..c82203f 100644
--- a/recipes/recipes.11tydata.js
+++ b/recipes/recipes.11tydata.js
@@ -218,6 +218,7 @@ const isNewestVersion = (filePath) => {
module.exports = {
layout: "recipe.njk",
tags: ["recipe"],
+ templateEngineOverride: "njk",
eleventyComputed: {
recipeSlug: (data) => {
return getSlugFromPath(data.page.inputPath);