Skip to content

Commit

Permalink
reset metaTag on page changing
Browse files Browse the repository at this point in the history
  • Loading branch information
yzlucas committed Nov 1, 2024
1 parent 489d414 commit 9e11795
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions client/wfnews-war/src/main/angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { MatDialog } from '@angular/material/dialog';
import { MatIconRegistry } from '@angular/material/icon';
import { DomSanitizer, Meta, Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { NavigationEnd, Router } from '@angular/router';
import { AppConfigService, TokenService } from '@wf1/core-ui';
import {
RouterLink,
Expand All @@ -37,6 +37,7 @@ import {
} from '@app/services/capacitor-service';
import { CommonUtilityService } from '@app/services/common-utility.service';
import { App, URLOpenListenerEvent } from '@capacitor/app';
import { filter } from 'rxjs/operators';

export const ICON = {
ADVISORIES: 'advisories',
Expand Down Expand Up @@ -272,20 +273,22 @@ export class AppComponent implements OnDestroy, OnInit, AfterViewInit {
);
}

this.setMetaTags();
this.router.events
.pipe(filter(event => event instanceof NavigationEnd))
.subscribe(() => {
this.setDefaultMetaTags();
});
}

setMetaTags(){
setDefaultMetaTags(){
const imageUrl = this.appConfigService.getConfig().application.baseUrl.toString() + 'assets/images/share-wildfire.png';
this.titleService.setTitle('BC Wildfire Service');

this.metaService.addTags([
{ property: 'og:title', content: 'BC Wildfire Service' },
{ property: 'og:image', content: imageUrl },
{ property: 'og:site_name', content: 'BC Wildfire Service' },
{ name: 'twitter:card', content: 'BC Wildfire Service' },
{ name: 'twitter:site', content: '@BCGovFireInfo' },
]);
this.metaService.updateTag({ property: 'og:title', content: 'BC Wildfire Service' });
this.metaService.updateTag({ property: 'og:image', content: imageUrl });
this.metaService.updateTag({ property: 'og:site_name', content: 'BC Wildfire Service' });
this.metaService.updateTag({ name: 'twitter:card', content: 'summary_large_image' });
this.metaService.updateTag({ name: 'twitter:site', content: '@BCGovFireInfo' });
}

initializeDeepLinks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class IncidentHeaderPanelComponent implements AfterViewInit, OnInit {
}
}
}
this.metaService.updateTag({ property: 'og:title', content: `Evacuation Alert for ${this.incident?.incidentName}`});
this.metaService.updateTag({ property: 'og:title', content: `${this.incident?.incidentName}`});
}

ngAfterViewInit(): void {
Expand Down

0 comments on commit 9e11795

Please sign in to comment.