feat: made default markdown not use the measurements plugin
This commit is contained in:
parent
63bd438e45
commit
2cbd931e99
5 changed files with 31 additions and 18 deletions
|
|
@ -30,7 +30,7 @@ pageType: recipe
|
|||
<div class="measurement-toggles" style="display: none;"></div>
|
||||
|
||||
<div class="recipe-content">
|
||||
{{ content | safe }}
|
||||
{{ content | renderRecipeMarkdown | safe }}
|
||||
</div>
|
||||
|
||||
{% set recipeTags = page.inputPath | extractTagsFromFile %}
|
||||
|
|
|
|||
|
|
@ -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 '<sup class="footnote-ref"><a href="#fn' + id + '" id="fnref' + refid + '">' + n + '</a></sup>';
|
||||
};
|
||||
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) => {
|
||||
|
|
|
|||
20
lib/footnotes/plugin.js
Normal file
20
lib/footnotes/plugin.js
Normal file
|
|
@ -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 '<sup class="footnote-ref"><a href="#fn' + id + '" id="fnref' + refid + '">' + n + '</a></sup>';
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = markdownItFootnoteCustom;
|
||||
|
|
@ -29,7 +29,7 @@ eleventyComputed:
|
|||
<div class="measurement-toggles" style="display: none;"></div>
|
||||
|
||||
<div class="recipe-content">
|
||||
{{ recipe.content | safe }}
|
||||
{{ recipe.content | renderRecipeMarkdown | safe }}
|
||||
</div>
|
||||
|
||||
{% set recipeTags = recipe.inputPath | extractTagsFromFile %}
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ const isNewestVersion = (filePath) => {
|
|||
module.exports = {
|
||||
layout: "recipe.njk",
|
||||
tags: ["recipe"],
|
||||
templateEngineOverride: "njk",
|
||||
eleventyComputed: {
|
||||
recipeSlug: (data) => {
|
||||
return getSlugFromPath(data.page.inputPath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue