markdown global rendering engine and link customization
This commit is contained in:
parent
b0994e0465
commit
b09d4a8591
|
@ -4,7 +4,6 @@ title: Programm
|
||||||
tags: mainNav
|
tags: mainNav
|
||||||
eleventyNavigation:
|
eleventyNavigation:
|
||||||
order: 1
|
order: 1
|
||||||
templateEngineOverride: njk,md
|
|
||||||
---
|
---
|
||||||
# Programm
|
# Programm
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ title: Program
|
||||||
tags: mainNav
|
tags: mainNav
|
||||||
eleventyNavigation:
|
eleventyNavigation:
|
||||||
order: 1
|
order: 1
|
||||||
templateEngineOverride: njk,md
|
|
||||||
---
|
---
|
||||||
# Program
|
# Program
|
||||||
|
|
||||||
|
|
|
@ -92,12 +92,7 @@ module.exports = function(eleventyConfig) {
|
||||||
return value.filter(item => item.page.lang === this.page.lang)
|
return value.filter(item => item.page.lang === this.page.lang)
|
||||||
});
|
});
|
||||||
|
|
||||||
eleventyConfig.addAsyncFilter('mdInline', async function(value) {
|
const md_link_open = function (tokens, idx, options, env, self) {
|
||||||
// TODO replace with ESM import once we switch to Eleventy v3
|
|
||||||
const md = (await import('markdown-it/index.mjs')).default();
|
|
||||||
|
|
||||||
// customize link rendering
|
|
||||||
md.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
|
||||||
const href = tokens[idx].attrGet('href');
|
const href = tokens[idx].attrGet('href');
|
||||||
|
|
||||||
if (href.startsWith('http')) {
|
if (href.startsWith('http')) {
|
||||||
|
@ -111,9 +106,18 @@ module.exports = function(eleventyConfig) {
|
||||||
return self.renderToken(tokens, idx, options);
|
return self.renderToken(tokens, idx, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
eleventyConfig.addAsyncFilter('mdInline', async function(value) {
|
||||||
|
// TODO replace with ESM import once we switch to Eleventy v3
|
||||||
|
const md = (await import('markdown-it/index.mjs')).default();
|
||||||
|
|
||||||
|
// customize link rendering
|
||||||
|
md.renderer.rules.link_open = md_link_open;
|
||||||
|
|
||||||
return md.renderInline(value);
|
return md.renderInline(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eleventyConfig.amendLibrary("md", mdLib => mdLib.renderer.rules.link_open = md_link_open);
|
||||||
|
|
||||||
// copy aileron font
|
// copy aileron font
|
||||||
eleventyConfig.addPassthroughCopy({'./submodules/aileron/fonts/*.(ttf|woff|woff2)': 'fonts'})
|
eleventyConfig.addPassthroughCopy({'./submodules/aileron/fonts/*.(ttf|woff|woff2)': 'fonts'})
|
||||||
eleventyConfig.addPassthroughCopy({'./submodules/aileron/aileron.lite.min.css': 'aileron.lite.min.css'})
|
eleventyConfig.addPassthroughCopy({'./submodules/aileron/aileron.lite.min.css': 'aileron.lite.min.css'})
|
||||||
|
@ -140,5 +144,6 @@ module.exports = function(eleventyConfig) {
|
||||||
includes: "../_includes",
|
includes: "../_includes",
|
||||||
},
|
},
|
||||||
pathPrefix: `/${eseData.year}/`,
|
pathPrefix: `/${eseData.year}/`,
|
||||||
|
markdownTemplateEngine: "njk",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue