From 61c5d2d8e01ace967157120727e3b3fcab541b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Thu, 25 Jan 2018 17:28:25 -0800 Subject: [PATCH] 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. --- lib/core/Site.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/core/Site.js b/lib/core/Site.js index 40823ad948d2..6ac9a235b286 100644 --- a/lib/core/Site.js +++ b/lib/core/Site.js @@ -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)} }); `,