Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: correct docs linking for custom defaultVersionShown #894

Merged
merged 1 commit into from
Aug 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/server/__tests__/docs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jest.mock('../env', () => ({
versioning: {
enabled: true,
defaultVersion: '1.0.0',
latestVersion: '1.0.0',
},
}));

Expand Down
2 changes: 1 addition & 1 deletion lib/server/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function mdToHtmlify(oldContent, mdToHtml, metadata) {
htmlLink = htmlLink.replace('/en/', `/${metadata.language}/`);
htmlLink = htmlLink.replace(
'/VERSION/',
metadata.version && metadata.version !== env.versioning.defaultVersion
metadata.version && metadata.version !== env.versioning.latestVersion
? `/${metadata.version}/`
: '/'
);
Expand Down
4 changes: 3 additions & 1 deletion lib/server/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Translation {
class Versioning {
constructor() {
this.enabled = false;
this.latestVersion = null;
this.defaultVersion = null;
this.versions = [];
this.missingVersionsPage = false;
Expand All @@ -64,9 +65,10 @@ class Versioning {
if (fs.existsSync(versionsJSONFile)) {
this.enabled = true;
this.versions = JSON.parse(fs.readFileSync(versionsJSONFile, 'utf8'));
this.latestVersion = this.versions[0];
this.defaultVersion = siteConfig.defaultVersionShown
? siteConfig.defaultVersionShown
: this.versions[0]; // otherwise show the latest version (other than next/master)
: this.latestVersion; // otherwise show the latest version (other than next/master)
}

if (!fs.existsSync(versionsFile)) {
Expand Down