Update canonical link with block hash

This commit is contained in:
Mononaut 2023-08-22 02:54:23 +09:00 committed by softsimon
parent b6f66a6a28
commit 368ab1dc66
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
3 changed files with 14 additions and 0 deletions

View File

@ -69,6 +69,7 @@ export class BisqBlockComponent implements OnInit, OnDestroy {
this.location.replaceState(
this.router.createUrlTree(['/bisq/block/', hash]).toString()
);
this.seoService.updateCanonical(this.location.path());
return this.bisqApiService.getBlock$(this.blockHash)
.pipe(catchError(this.caughtHttpError.bind(this)));
}),

View File

@ -202,6 +202,7 @@ export class BlockComponent implements OnInit, OnDestroy {
this.location.replaceState(
this.router.createUrlTree([(this.network ? '/' + this.network : '') + '/block/', hash]).toString()
);
this.seoService.updateCanonical(this.location.path());
return this.apiService.getBlock$(hash).pipe(
catchError((err) => {
this.error = err;

View File

@ -12,6 +12,8 @@ export class SeoService {
baseTitle = 'mempool';
baseDescription = 'Explore the full Bitcoin ecosystem with The Mempool Open Project™.';
canonicalLink: HTMLElement = document.getElementById('canonical');
constructor(
private titleService: Title,
private metaService: Meta,
@ -65,6 +67,16 @@ export class SeoService {
this.metaService.updateTag({ property: 'og:description', content: this.getDescription()});
}
updateCanonical(path) {
let domain = 'mempool.space';
if (this.stateService.env.BASE_MODULE === 'liquid') {
domain = 'liquid.network';
} else if (this.stateService.env.BASE_MODULE === 'bisq') {
domain = 'bisq.markets';
}
this.canonicalLink.setAttribute('href', 'https://' + domain + path);
}
getTitle(): string {
if (this.network === 'testnet')
return this.baseTitle + ' - Bitcoin Testnet';