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); let mdMatch = mdRegex.exec(modifiedLine);
while (mdMatch !== null) { while (mdMatch !== null) {
/* Replace it to correct html link */ /* Replace it to correct html link */
const docsSource = metadata.version
? metadata.source.replace(/version-.*?\//, '')
: metadata.source;
let htmlLink = let htmlLink =
mdToHtml[resolve(metadata.source, mdMatch[1])] || mdToHtml[mdMatch[1]]; mdToHtml[resolve(docsSource, mdMatch[1])] || mdToHtml[mdMatch[1]];
if (htmlLink) { if (htmlLink) {
htmlLink = getPath(htmlLink, siteConfig.cleanUrl); htmlLink = getPath(htmlLink, siteConfig.cleanUrl);
htmlLink = htmlLink.replace('/en/', `/${metadata.language}/`); htmlLink = htmlLink.replace('/en/', `/${metadata.language}/`);

View file

@ -53,6 +53,15 @@ if (env.versioning.missingVersionsPage) {
process.exit(1); process.exit(1);
} }
if (version.includes('/')) {
console.error(
`${chalk.red(
'Invalid version number specified! Do not include slash (/). Try something like: 1.0.0',
)}`,
);
process.exit(1);
}
if (typeof version === 'undefined') { if (typeof version === 'undefined') {
console.error( console.error(
`${chalk.yellow( `${chalk.yellow(