Skip to content

Commit

Permalink
Fix for handling new version where only a subset of docs contents are…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
parkas2018 committed Oct 18, 2019
1 parent c21a4bc commit 191044d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/docusaurus-1.x/lib/server/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}/`);
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-1.x/lib/server/readMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,4 +404,5 @@ module.exports = {
processMetadata,
generateMetadataDocs,
generateMetadataBlog,
shouldGenerateNextReleaseDocs,
};

0 comments on commit 191044d

Please sign in to comment.