mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 17:17:28 +02:00
fix: relative path markdown linking on versioned docs (#1281)
This commit is contained in:
parent
d78220a818
commit
63f014fce5
2 changed files with 13 additions and 1 deletions
|
@ -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}/`);
|
||||
|
|
|
@ -53,6 +53,15 @@ if (env.versioning.missingVersionsPage) {
|
|||
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') {
|
||||
console.error(
|
||||
`${chalk.yellow(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue