This repository was archived by the owner on Oct 1, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-15
lines changed
operators/components/operator Expand file tree Collapse file tree 3 files changed +17
-15
lines changed Original file line number Diff line number Diff line change 66 RouterEvent
77} from '@angular/router' ;
88import { filter , map , mergeMap } from 'rxjs/operators' ;
9- import { SeoService } from './services/seo.service' ;
9+ import { SeoService , SeoData } from './services/seo.service' ;
1010
1111interface Menu {
1212 title : string ;
@@ -61,12 +61,9 @@ export class AppComponent implements OnInit {
6161 return route ;
6262 } ) ,
6363 filter ( route => route . outlet === 'primary' ) ,
64- mergeMap ( route => route . data )
64+ mergeMap ( route => route . data ) ,
65+ filter ( ( data : SeoData ) => data . title !== undefined )
6566 )
66- . subscribe ( data => {
67- if ( data !== { } ) {
68- this . _seo . setHeaders ( data . title || [ ] , data . description || '' ) ;
69- }
70- } ) ;
67+ . subscribe ( ( data : SeoData ) => this . _seo . setHeaders ( data ) ) ;
7168 }
7269}
Original file line number Diff line number Diff line change @@ -39,12 +39,12 @@ export class OperatorComponent implements OnInit {
3939 this . operators . filter (
4040 ( operator : OperatorDoc ) => operator . name === name
4141 ) [ 0 ] || this . notfound ( ) ;
42- this . _seo . setHeaders (
43- [ this . operator . name , this . operator . operatorType ] ,
44- this . operator . shortDescription
42+ this . _seo . setHeaders ( {
43+ title : [ this . operator . name , this . operator . operatorType ] ,
44+ description : this . operator . shortDescription
4545 ? this . operator . shortDescription . description
4646 : ''
47- ) ;
47+ } ) ;
4848 } ) ;
4949 }
5050
Original file line number Diff line number Diff line change 11import { Injectable } from '@angular/core' ;
22import { Title , Meta } from '@angular/platform-browser' ;
33
4+ export interface SeoData {
5+ title ?: string [ ] ;
6+ description ?: string ;
7+ }
8+
49@Injectable ( )
510export class SeoService {
611 // This part is happended at the end of head>title
712 private siteTitle = 'RxJS Documentation' ;
813
914 constructor ( private _title : Title , private _meta : Meta ) { }
1015
11- public setHeaders ( titleParts : string [ ] , description : string ) {
12- this . _title . setTitle ( [ ...titleParts , this . siteTitle ] . join ( ' \u2022 ' ) ) ;
13- if ( description && description . length ) {
16+ public setHeaders ( data : SeoData ) {
17+ this . _title . setTitle ( [ ...data . title , this . siteTitle ] . join ( ' \u2022 ' ) ) ;
18+ if ( data . description && data . description . length ) {
1419 this . _meta . updateTag ( {
15- content : description ,
20+ content : data . description ,
1621 name : 'description'
1722 } ) ;
1823 }
You can’t perform that action at this time.
0 commit comments