Commit 2615b712 authored by Maxym Borodenko's avatar Maxym Borodenko

Indicating alternate pages

parent d710b8bc
......@@ -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