diff --git a/content/de/program.md b/content/de/program.md index bb988e2..1b69436 100644 --- a/content/de/program.md +++ b/content/de/program.md @@ -4,7 +4,6 @@ title: Programm tags: mainNav eleventyNavigation: order: 1 -templateEngineOverride: njk,md --- # Programm diff --git a/content/en/program.md b/content/en/program.md index 46b04ae..7b1c034 100644 --- a/content/en/program.md +++ b/content/en/program.md @@ -4,7 +4,6 @@ title: Program tags: mainNav eleventyNavigation: order: 1 -templateEngineOverride: njk,md --- # Program diff --git a/eleventy.config.js b/eleventy.config.js index a519c71..76e8f0e 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -92,28 +92,32 @@ module.exports = function(eleventyConfig) { return value.filter(item => item.page.lang === this.page.lang) }); + const md_link_open = function (tokens, idx, options, env, self) { + const href = tokens[idx].attrGet('href'); + + if (href.startsWith('http')) { + tokens[idx].attrSet('target', '_blank'); + tokens[idx].attrSet('rel', 'noreferrer'); + } else { + const newHref = eleventyConfig.javascriptFunctions.locale_url(href); + tokens[idx].attrSet('href', newHref); + } + + 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 = function (tokens, idx, options, env, self) { - const href = tokens[idx].attrGet('href'); - - if (href.startsWith('http')) { - tokens[idx].attrSet('target', '_blank'); - tokens[idx].attrSet('rel', 'noreferrer'); - } else { - const newHref = eleventyConfig.javascriptFunctions.locale_url(href); - tokens[idx].attrSet('href', newHref); - } - - return self.renderToken(tokens, idx, options); - }; + md.renderer.rules.link_open = md_link_open; return md.renderInline(value); }); + eleventyConfig.amendLibrary("md", mdLib => mdLib.renderer.rules.link_open = md_link_open); + // copy aileron font eleventyConfig.addPassthroughCopy({'./submodules/aileron/fonts/*.(ttf|woff|woff2)': 'fonts'}) eleventyConfig.addPassthroughCopy({'./submodules/aileron/aileron.lite.min.css': 'aileron.lite.min.css'}) @@ -140,5 +144,6 @@ module.exports = function(eleventyConfig) { includes: "../_includes", }, pathPrefix: `/${eseData.year}/`, + markdownTemplateEngine: "njk", } };