Commit 639d2e45 authored by Matija Obreza's avatar Matija Obreza

Merge branch '281-indicating-alternate-pages'

* 281-indicating-alternate-pages:
  Indicating alternate pages
parents 9bd4854d 2615b712
......@@ -69,6 +69,17 @@ class App extends React.Component<IAppProps, any> {
const {updateHistory} = this.props;
if (this.props.location !== null && nextProps.location !== null) {
if (this.props.location !== nextProps.location) {
if (typeof window !== 'undefined') {
const origin = window.location.origin;
const path = nextProps.location.pathname + nextProps.location.search;
const links = [...document.getElementsByTagName('html')[0].getElementsByTagName('link')];
links.forEach((l) => {
if (l.getAttribute('rel') === 'alternate') {
const lang = l.getAttribute('hreflang') === 'en' ? '' : `/${l.getAttribute('hreflang')}`;
l.setAttribute('href', `${origin + lang + path}`);
}
});
}
updateHistory(this.props.location.pathname);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment