From 191044d24da3e0be8d33bede0b65efbfbce648ac Mon Sep 17 00:00:00 2001 From: Parvez Akkas Date: Thu, 17 Oct 2019 20:33:38 -0400 Subject: [PATCH] Fix for handling new version where only a subset of docs contents are different The previous commit would fix the borken relative links involving `--skip-next-release` when the very first/initial version is created or if **all** docs were updated before creating a version. If only a few/one doc was updated before creating a version, there would still be broken relative links when building the site with `--skip-next-release` docs. This commit fixes the issues mentioned above. --- packages/docusaurus-1.x/lib/server/docs.js | 14 ++++++++++++-- packages/docusaurus-1.x/lib/server/readMetadata.js | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-1.x/lib/server/docs.js b/packages/docusaurus-1.x/lib/server/docs.js index ddd0cfc7d21c9..441b6d4547efe 100644 --- a/packages/docusaurus-1.x/lib/server/docs.js +++ b/packages/docusaurus-1.x/lib/server/docs.js @@ -69,9 +69,19 @@ function mdToHtmlify(oldContent, mdToHtml, metadata, siteConfig) { let mdMatch = mdRegex.exec(modifiedLine); while (mdMatch !== null) { /* Replace it to correct html link */ - const docsSource = metadata.source; + let docsSource; + if (readMetadata.shouldGenerateNextReleaseDocs()) { + docsSource = metadata.version + ? metadata.source.replace(/version-.*?\//, '') + : metadata.source; + } else { + docsSource = metadata.source; + } let htmlLink = - mdToHtml[resolve(docsSource, mdMatch[1])] || mdToHtml[mdMatch[1]]; + mdToHtml[resolve(docsSource, mdMatch[1])] || + mdToHtml[mdMatch[1]] || + resolve(docsSource, mdMatch[1]).replace('.md', '.html'); + if (htmlLink) { htmlLink = getPath(htmlLink, siteConfig.cleanUrl); htmlLink = htmlLink.replace('/en/', `/${metadata.language}/`); diff --git a/packages/docusaurus-1.x/lib/server/readMetadata.js b/packages/docusaurus-1.x/lib/server/readMetadata.js index 20d0409dfda2f..810af051e0dc7 100644 --- a/packages/docusaurus-1.x/lib/server/readMetadata.js +++ b/packages/docusaurus-1.x/lib/server/readMetadata.js @@ -404,4 +404,5 @@ module.exports = { processMetadata, generateMetadataDocs, generateMetadataBlog, + shouldGenerateNextReleaseDocs, };