mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-15 10:07:33 +02:00
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:
parent
3e824afe97
commit
61c5d2d8e0
1 changed files with 6 additions and 3 deletions
|
@ -30,7 +30,7 @@ class Site extends React.Component {
|
||||||
this.props.config.url +
|
this.props.config.url +
|
||||||
this.props.config.baseUrl +
|
this.props.config.baseUrl +
|
||||||
(this.props.url || 'index.html');
|
(this.props.url || 'index.html');
|
||||||
let latestVersion;
|
let docsVersion = this.props.version || 'current';
|
||||||
|
|
||||||
const highlightDefaultVersion = '9.12.0';
|
const highlightDefaultVersion = '9.12.0';
|
||||||
const highlightConfig = this.props.config.highlight || {
|
const highlightConfig = this.props.config.highlight || {
|
||||||
|
@ -39,7 +39,10 @@ class Site extends React.Component {
|
||||||
};
|
};
|
||||||
const highlightVersion = highlightConfig.version || highlightDefaultVersion;
|
const highlightVersion = highlightConfig.version || highlightDefaultVersion;
|
||||||
if (fs.existsSync(CWD + '/versions.json')) {
|
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
|
// 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(
|
algoliaOptions: ${JSON.stringify(
|
||||||
this.props.config.algolia.algoliaOptions
|
this.props.config.algolia.algoliaOptions
|
||||||
)
|
)
|
||||||
.replace('VERSION', this.props.version || latestVersion)
|
.replace('VERSION', docsVersion)
|
||||||
.replace('LANGUAGE', this.props.language)}
|
.replace('LANGUAGE', this.props.language)}
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue