mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 05:27:00 +02:00
fix(v1): versioned_docs and skip-next-release relative path issue by adding versioned_source to metadata (#3429)
This commit is contained in:
parent
94527b0b62
commit
d280176806
7 changed files with 32 additions and 8 deletions
|
@ -69,17 +69,20 @@ function mdToHtmlify(oldContent, mdToHtml, metadata, siteConfig) {
|
|||
let mdMatch = mdRegex.exec(modifiedLine);
|
||||
while (mdMatch !== null) {
|
||||
/* Replace it to correct html link */
|
||||
const docsSource = metadata.version
|
||||
? metadata.source.replace(/version-.*?\//, '')
|
||||
: metadata.source;
|
||||
const docsSource =
|
||||
metadata.version && readMetadata.shouldGenerateNextReleaseDocs()
|
||||
? metadata.versioned_source.replace(/version-.*?\//, '')
|
||||
: metadata.versioned_source;
|
||||
let htmlLink =
|
||||
mdToHtml[resolve(docsSource, mdMatch[1])] || mdToHtml[mdMatch[1]];
|
||||
if (htmlLink) {
|
||||
htmlLink = getPath(htmlLink, siteConfig.cleanUrl);
|
||||
htmlLink = htmlLink.replace('/en/', `/${metadata.language}/`);
|
||||
htmlLink = htmlLink.replace(
|
||||
'/VERSION/',
|
||||
metadata.version && metadata.version !== env.versioning.latestVersion
|
||||
/\/VERSION\/(next\/)?/,
|
||||
metadata.version &&
|
||||
metadata.version !== env.versioning.latestVersion &&
|
||||
readMetadata.shouldGenerateNextReleaseDocs()
|
||||
? `/${metadata.version}/`
|
||||
: '/',
|
||||
);
|
||||
|
@ -95,7 +98,7 @@ function mdToHtmlify(oldContent, mdToHtml, metadata, siteConfig) {
|
|||
|
||||
if (mdBrokenLinks.length) {
|
||||
console.log(
|
||||
`[WARN] unresolved links in file '${metadata.source}' >`,
|
||||
`[WARN] unresolved links in file '${metadata.versioned_source}' >`,
|
||||
mdBrokenLinks,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue