mempool/frontend/src/app/services/seo.service.ts

34 lines
808 B
TypeScript
Raw Normal View History

2020-03-24 00:52:08 +07:00
import { Injectable } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { StateService } from './state.service';
2020-03-24 00:52:08 +07:00
@Injectable({
providedIn: 'root'
})
export class SeoService {
network = '';
2020-03-24 00:52:08 +07:00
constructor(
private titleService: Title,
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-03-24 00:52:08 +07:00
}
2020-08-12 14:04:04 +07:00
resetTitle(): void {
this.titleService.setTitle(this.getTitle());
}
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
}
}