Skip to content

Commit

Permalink
fix lint, add gtag
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenFluin committed Mar 26, 2021
1 parent 61b93c5 commit 947718c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { trigger, transition, group, query, style, animate } from '@angular/anim
import { filter } from 'rxjs/operators';

declare var ga: any;
declare var gtag: any;

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
Expand Down Expand Up @@ -53,10 +55,10 @@ export class AppComponent {
}
return this._maxHeight;
}
@ViewChild('container', {static: false}) container: ElementRef;
@ViewChild('container', { static: false }) container: ElementRef;

constructor(router: Router, activatedRoute: ActivatedRoute, title: Title, meta: Meta) {
router.events.pipe(filter(e => e instanceof NavigationEnd)).subscribe((n: NavigationEnd) => {
router.events.pipe(filter((e) => e instanceof NavigationEnd)).subscribe((n: NavigationEnd) => {
const pageTitle = router.routerState.snapshot.root.children[0].data['title'];
if (pageTitle) {
title.setTitle(pageTitle);
Expand All @@ -65,15 +67,15 @@ export class AppComponent {
}
window.scrollTo(0, 0);
ga('send', 'pageview', n.urlAfterRedirects);
gtag('config', 'G-2CB60WKV1M', { page_path: n.urlAfterRedirects });
});
router.events.pipe(filter(e => e instanceof NavigationStart)).subscribe(next => {
router.events.pipe(filter((e) => e instanceof NavigationStart)).subscribe((next) => {
meta.removeTag('name=robots');

if (this.container) {
this._maxHeight = null;
}
});

}

/** Get the current page for route animation purposes */
Expand Down
2 changes: 1 addition & 1 deletion src/app/embeddable/post-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PostService, Post } from 'app/shared/post.service';
<div id="posts-block">
<a class="card featured-blog-post" *ngFor="let post of posts | async" [routerLink]="['blog',post.id]">
<div class="post-image" *ngIf="!post.image" style="background-image: url('/assets/images/imgpostholder.png')"></div>
<div class="post-image" *ngIf="post.image" [style.background-image]="'url('+post.image+')'"></div>
<div class="post-image" *ngIf="post.image" [style.background-image]="'url(\\'' + post.image + '\\')'"></div>
<div class="post-details">
<h4 class="post-title">
{{post.title}}
Expand Down
8 changes: 8 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@

ga('create', 'UA-66278430-2', 'auto');

</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2CB60WKV1M"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

</script>

<script>
Expand Down

0 comments on commit 947718c

Please sign in to comment.