mirror of
https://github.com/mempool/mempool.git
synced 2024-12-28 01:04:28 +01:00
Restoring dynamic canonical URL.
This commit is contained in:
parent
3b380fa4cc
commit
b34648389c
@ -1,5 +1,5 @@
|
|||||||
import { Component, HostListener } from '@angular/core';
|
import { Component, HostListener, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router, NavigationEnd } from '@angular/router';
|
||||||
import { WebsocketService } from '../../services/websocket.service';
|
import { WebsocketService } from '../../services/websocket.service';
|
||||||
import { StateService } from 'src/app/services/state.service';
|
import { StateService } from 'src/app/services/state.service';
|
||||||
|
|
||||||
@ -8,8 +8,7 @@ import { StateService } from 'src/app/services/state.service';
|
|||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.scss']
|
styleUrls: ['./app.component.scss']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent implements OnInit {
|
||||||
network = '';
|
|
||||||
link: HTMLLinkElement;
|
link: HTMLLinkElement;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -26,4 +25,22 @@ export class AppComponent {
|
|||||||
this.stateService.keyNavigation$.next(event);
|
this.stateService.keyNavigation$.next(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.router.events.subscribe((val) => {
|
||||||
|
if (val instanceof NavigationEnd) {
|
||||||
|
this.updateCanonicalUrlElement('https://mempool.space' + location.pathname);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCanonicalUrlElement(url: string) {
|
||||||
|
if (!this.link) {
|
||||||
|
this.link = window.document.createElement('link');
|
||||||
|
this.link.setAttribute('rel', 'canonical');
|
||||||
|
window.document.head.appendChild(this.link);
|
||||||
|
}
|
||||||
|
this.link.setAttribute('href', url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user