2020-03-24 00:52:08 +07:00
|
|
|
import { Injectable } from '@angular/core';
|
2020-11-20 00:59:10 +09:00
|
|
|
import { Title, Meta } from '@angular/platform-browser';
|
2020-05-09 20:37:50 +07:00
|
|
|
import { StateService } from './state.service';
|
2020-03-24 00:52:08 +07:00
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class SeoService {
|
2020-05-09 20:37:50 +07:00
|
|
|
network = '';
|
2020-03-24 00:52:08 +07:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private titleService: Title,
|
2020-11-20 00:59:10 +09:00
|
|
|
private metaService: Meta,
|
2020-05-09 20:37:50 +07:00
|
|
|
private stateService: StateService,
|
|
|
|
) {
|
|
|
|
this.stateService.networkChanged$.subscribe((network) => this.network = network);
|
|
|
|
}
|
2020-03-24 00:52:08 +07:00
|
|
|
|
2020-08-12 14:04:04 +07:00
|
|
|
setTitle(newTitle: string): void {
|
|
|
|
this.titleService.setTitle(newTitle + ' - ' + this.getTitle());
|
2020-11-20 00:59:10 +09:00
|
|
|
this.metaService.updateTag({ property: 'og:title', content: newTitle});
|
2020-03-24 00:52:08 +07:00
|
|
|
}
|
|
|
|
|
2020-08-12 14:04:04 +07:00
|
|
|
resetTitle(): void {
|
|
|
|
this.titleService.setTitle(this.getTitle());
|
2020-11-20 00:59:10 +09:00
|
|
|
this.metaService.updateTag({ property: 'og:title', content: this.getTitle()});
|
2020-08-12 14:04:04 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
getTitle(): string {
|
|
|
|
return 'mempool - ' + (this.network ? this.ucfirst(this.network) : 'Bitcoin') + ' Explorer';
|
|
|
|
}
|
|
|
|
|
|
|
|
ucfirst(str: string) {
|
|
|
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
2020-03-24 00:52:08 +07:00
|
|
|
}
|
|
|
|
}
|