Merge pull request #183 from mempool/wiz/angular-universal

Update `og:title` meta tag when changing page title
This commit is contained in:
softsimon 2020-11-20 00:46:04 +07:00 committed by GitHub
commit 36022680cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Title, Meta } from '@angular/platform-browser';
import { StateService } from './state.service';
@Injectable({
@ -10,6 +10,7 @@ export class SeoService {
constructor(
private titleService: Title,
private metaService: Meta,
private stateService: StateService,
) {
this.stateService.networkChanged$.subscribe((network) => this.network = network);
@ -17,10 +18,12 @@ export class SeoService {
setTitle(newTitle: string): void {
this.titleService.setTitle(newTitle + ' - ' + this.getTitle());
this.metaService.updateTag({ property: 'og:title', content: newTitle});
}
resetTitle(): void {
this.titleService.setTitle(this.getTitle());
this.metaService.updateTag({ property: 'og:title', content: this.getTitle()});
}
getTitle(): string {