mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-07-13 08:07:11 +02:00
Rewrite manual links for website output
This commit is contained in:
+24
-1
@@ -3,6 +3,29 @@ const path = require("path");
|
|||||||
const markdownIt = require("markdown-it");
|
const markdownIt = require("markdown-it");
|
||||||
const markdownItAnchor = require("markdown-it-anchor");
|
const markdownItAnchor = require("markdown-it-anchor");
|
||||||
|
|
||||||
|
function rewriteManualLinks(content, lang) {
|
||||||
|
return (content || "")
|
||||||
|
// GitHub-Wiki-Links im Stil [[de-Installation]] oder [[en-Installation]]
|
||||||
|
.replace(/\[\[(en|de)-([^\]|]+)\]\]/g, (match, linkLang, slug) => {
|
||||||
|
return `[${slug.replace(/-/g, " ")}](/manual/${linkLang}/${slug.toLowerCase()}/)`;
|
||||||
|
})
|
||||||
|
|
||||||
|
// GitHub-Wiki-Links mit Label: [[Text|de-Installation]]
|
||||||
|
.replace(/\[\[([^\]|]+)\|(en|de)-([^\]]+)\]\]/g, (match, label, linkLang, slug) => {
|
||||||
|
return `[${label}](/manual/${linkLang}/${slug.toLowerCase()}/)`;
|
||||||
|
})
|
||||||
|
|
||||||
|
// Markdown-Links auf de-/en-Dateien ohne .md
|
||||||
|
.replace(/\]\((en|de)-([^)#]+)\)/g, (match, linkLang, slug) => {
|
||||||
|
return `](/manual/${linkLang}/${slug.toLowerCase()}/)`;
|
||||||
|
})
|
||||||
|
|
||||||
|
// Markdown-Links auf de-/en-Dateien mit .md
|
||||||
|
.replace(/\]\((en|de)-([^)#]+)\.md\)/g, (match, linkLang, slug) => {
|
||||||
|
return `](/manual/${linkLang}/${slug.toLowerCase()}/)`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = function (eleventyConfig) {
|
module.exports = function (eleventyConfig) {
|
||||||
eleventyConfig.addPassthroughCopy({ "src/assets": "assets" });
|
eleventyConfig.addPassthroughCopy({ "src/assets": "assets" });
|
||||||
|
|
||||||
@@ -49,7 +72,7 @@ module.exports = function (eleventyConfig) {
|
|||||||
lang,
|
lang,
|
||||||
slug,
|
slug,
|
||||||
title,
|
title,
|
||||||
content: raw
|
content: rewriteManualLinks(raw, lang)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user