Treat latest version as current version (#418)

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.
This commit is contained in:
Héctor Ramos 2018-01-25 17:28:25 -08:00 committed by Joel Marcey
parent 3e824afe97
commit 61c5d2d8e0

View file

@ -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 || {
@ -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
@ -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)}
});
`,