fix: relative path markdown linking on versioned docs (#1281)

This commit is contained in:
Endilie Yacop Sucipto 2019-03-14 16:03:42 +08:00 committed by GitHub
parent d78220a818
commit 63f014fce5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -73,8 +73,11 @@ function mdToHtmlify(oldContent, mdToHtml, metadata) {
let mdMatch = mdRegex.exec(modifiedLine);
while (mdMatch !== null) {
/* Replace it to correct html link */
const docsSource = metadata.version
? metadata.source.replace(/version-.*?\//, '')
: metadata.source;
let htmlLink =
mdToHtml[resolve(metadata.source, mdMatch[1])] || mdToHtml[mdMatch[1]];
mdToHtml[resolve(docsSource, mdMatch[1])] || mdToHtml[mdMatch[1]];
if (htmlLink) {
htmlLink = getPath(htmlLink, siteConfig.cleanUrl);
htmlLink = htmlLink.replace('/en/', `/${metadata.language}/`);