diff --git a/website/.eleventy.js b/website/.eleventy.js index 411ef958d5..ddbed4bc9c 100644 --- a/website/.eleventy.js +++ b/website/.eleventy.js @@ -18,19 +18,47 @@ module.exports = function (eleventyConfig) { const markdownIt = require("markdown-it"); const markdownItAnchor = require("markdown-it-anchor"); + const markdownItReplaceLink = require('markdown-it-replace-link'); const slugify = require("slugify"); const markdownLib = markdownIt({ html: true, breaks: true, - linkify: true + linkify: true, + replaceLink: function (link, env) { + const dotSepList = link.split("."); + if (dotSepList[0] == "") { + const hashSepList = dotSepList[dotSepList.length - 1].split("#") + if (hashSepList[0] == "md") { + let str = `.${dotSepList[1]}`; + for (let i = 2; i < dotSepList.length; i++) { + if (dotSepList[i].substring(0, 2) != "md") { + str += "." + dotSepList[i]; + } else { + str += ".html"; + break; + }; + } + if (hashSepList[1]) { + str += "#" + hashSepList[1]; + } + return str; + } + else { + return link; + } + } + else { + return link; + } + } }).use(markdownItAnchor, { slugify: (str) => slugify(str, { lower: true, strict: true, }) - }); + }).use(markdownItReplaceLink); // replace the default markdown-it instance eleventyConfig.setLibrary("md", markdownLib); diff --git a/website/package.json b/website/package.json index 38b531cdff..ef8bf89b4d 100644 --- a/website/package.json +++ b/website/package.json @@ -19,5 +19,8 @@ "markdown-it-anchor": "^8.6.4", "slugify": "^1.6.5", "tailwindcss": "^3.0.24" + }, + "dependencies": { + "markdown-it-replace-link": "^1.1.0" } } diff --git a/website/src/_includes/layouts/article.html b/website/src/_includes/layouts/article.html index ab67b29a81..2982be2912 100644 --- a/website/src/_includes/layouts/article.html +++ b/website/src/_includes/layouts/article.html @@ -19,8 +19,6 @@