Skip to content

Commit

Permalink
Treat latest version as current version (#418)
Browse files Browse the repository at this point in the history
If the site is versioned, and the latest version is displayed, the URL will not change. We need to let Algolia know this is the case.
  • Loading branch information
hramos authored and JoelMarcey committed Jan 26, 2018
1 parent 3e824af commit 61c5d2d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/core/Site.js
Expand Up @@ -30,7 +30,7 @@ class Site extends React.Component {
this.props.config.url +
this.props.config.baseUrl +
(this.props.url || 'index.html');
let latestVersion;
let docsVersion = this.props.version || 'current';

const highlightDefaultVersion = '9.12.0';
const highlightConfig = this.props.config.highlight || {
Expand All @@ -39,7 +39,10 @@ class Site extends React.Component {
};
const highlightVersion = highlightConfig.version || highlightDefaultVersion;
if (fs.existsSync(CWD + '/versions.json')) {
latestVersion = require(CWD + '/versions.json')[0];
const latestVersion = require(CWD + '/versions.json')[0];
if (docsVersion === latestVersion) {
docsVersion = 'current';
}
}

// We do not want a lang attribute for the html tag if we don't have a language set
Expand Down Expand Up @@ -122,7 +125,7 @@ class Site extends React.Component {
algoliaOptions: ${JSON.stringify(
this.props.config.algolia.algoliaOptions
)
.replace('VERSION', this.props.version || latestVersion)
.replace('VERSION', docsVersion)
.replace('LANGUAGE', this.props.language)}
});
`,
Expand Down

0 comments on commit 61c5d2d

Please sign in to comment.