diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2018-11-05 10:54:14 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-11-08 20:20:57 +0100 |
commit | 6b837953f06bfd5181580144c955284f168c844e (patch) | |
tree | 5daabb1e036d3b9238251a20a7aac5596fd5ba42 /server/sonar-docs/src/templates | |
parent | 682ce8e34518e92aea88b368f1d4d1d99a0c6be7 (diff) | |
download | sonarqube-6b837953f06bfd5181580144c955284f168c844e.tar.gz sonarqube-6b837953f06bfd5181580144c955284f168c844e.zip |
SONAR-11442 Fix canonical in docs static website
Diffstat (limited to 'server/sonar-docs/src/templates')
-rw-r--r-- | server/sonar-docs/src/templates/page.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/server/sonar-docs/src/templates/page.js b/server/sonar-docs/src/templates/page.js index 93d7f2750e0..cd29d8180ad 100644 --- a/server/sonar-docs/src/templates/page.js +++ b/server/sonar-docs/src/templates/page.js @@ -25,7 +25,12 @@ import './page.css'; const version = process.env.GATSBY_DOCS_VERSION || '1.0'; export default class Page extends React.PureComponent { + baseUrl = ''; + componentDidMount() { + if (window) { + this.baseUrl = window.location.origin + '/'; + } const collaspables = document.getElementsByClassName('collapse'); for (let i = 0; i < collaspables.length; i++) { collaspables[i].classList.add('close'); @@ -63,7 +68,10 @@ export default class Page extends React.PureComponent { <Helmet title={page.frontmatter.title || 'Documentation'}> <html lang="en" /> <link rel="icon" href={`/${version}/favicon.ico`} /> - <link rel="canonical" href={this.props.location.pathname.replace('latest', version)} /> + <link + rel="canonical" + href={this.baseUrl + this.props.location.pathname.replace(version, 'latest')} + /> </Helmet> <HeaderList headers={realHeadingsList} /> <h1>{page.frontmatter.title}</h1> |