Project

General

Profile

« Previous | Next » 

Revision 59854

SEO updates:
-titles, meta description json ld
-piwik calls
-sitemap.xml
-robots.txt
-add error page

View differences:

home.component.ts
1 1
import {Component, OnInit, ViewChild} from '@angular/core';
2 2
import {ActivatedRoute, Router} from '@angular/router';
3
import {Title} from '@angular/platform-browser';
3
import {Meta, Title} from '@angular/platform-browser';
4 4
import {FullPageSliderComponent} from '../openaireLibrary/utils/full-page-slider/full-page-slider.component';
5
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
6
import {Subscription} from 'rxjs';
7
import {properties} from '../../environments/environment';
8
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
9
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
5 10

  
6 11
@Component({
7 12
  selector: 'home',
......
14 19
  public fragments: string[] = ['', 'why', 'who', 'features'];
15 20
  @ViewChild("slider")
16 21
  public slider: FullPageSliderComponent;
17
  
22
  properties: EnvProperties = properties;
23

  
24
  subs: Subscription[] = [];
18 25
  constructor(private route: ActivatedRoute,
19 26
              private router: Router,
20
              private title: Title) {}
27
              private _title: Title, private _piwikService: PiwikService,
28
              private _meta: Meta, private seoService: SEOService
29
  ) {}
21 30
  
22
  ngOnInit() {
23
    this.title.setTitle('OpenAIRE - UsageCounts');
24
    this.route.fragment.subscribe(name => {
31
  ngOnInit()
32
  {
33
    let description = "UsageCounts service collects usage data from repositories, journals and other scientific data sources, aggregates them and delivers standardized activity reports about research usage and uptake. It complements existing citation mechanisms and assists institutional repository managers, research communities, research organizations, funders and policy makers track and evaluate research from an early stage.";
34
    let title = "OpenAIRE - UsageCounts";
35
    this._title.setTitle(title);
36
    this._meta.updateTag({content: description}, "name='description'");
37
    this._meta.updateTag({content: description}, "property='og:description'");
38
    this._meta.updateTag({content: title}, "property='og:title'");
39
    this._title.setTitle(title);
40
    let url = this.properties.domain + this.properties.baseLink + this.router.url;
41
    this.seoService.createLinkForCanonicalURL(url, false);
42
    this._meta.updateTag({content: url}, "property='og:url'");
43
    if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
44
      this.subs.push(this._piwikService.trackView(this.properties, title).subscribe());
45
    }
46
    this.subs.push(this.route.fragment.subscribe(name => {
25 47
      if(name) {
26 48
        let slide = this.fragments.findIndex(fragment => fragment === name) + 1;
27 49
        if(slide > 0) {
28 50
          this.initSlide = slide;
29 51
        }
30 52
      }
31
    });
32
    this.slider.stateAsObservable.subscribe(state => {
53
    }));
54
    this.subs.push(this.slider.stateAsObservable.subscribe(state => {
33 55
      if(state == 1) {
34 56
        this.router.navigate(['/']);
35 57
      } else {
36 58
        this.router.navigate(['/'], {fragment: this.fragments[state - 1]});
37 59
      }
38
    });
60
    }));
39 61
  }
62
  public ngOnDestroy() {
63
    for (let sub of this.subs) {
64
      sub.unsubscribe();
65
    }
66
  }
67

  
40 68
}

Also available in: Unified diff