Skip to content

Commit 26a7b93

Browse files
feat(docs): add dynamic meta tags and title for docs pages
1 parent 49996bd commit 26a7b93

File tree

2 files changed

+162
-3
lines changed

2 files changed

+162
-3
lines changed

docs/src/app/documentation/page/page.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { Component, Inject, NgZone, OnDestroy, OnInit, ViewChild, AfterContentChecked } from '@angular/core';
8-
import { Title } from '@angular/platform-browser';
8+
import { Meta, Title } from '@angular/platform-browser';
99
import { ActivatedRoute, Router } from '@angular/router';
1010
import { filter, map, publishReplay, refCount, tap, takeWhile } from 'rxjs/operators';
1111
import { NB_WINDOW } from '@nebular/theme';
@@ -31,7 +31,8 @@ export class NgdPageComponent implements OnInit, AfterContentChecked, OnDestroy
3131
private router: Router,
3232
private activatedRoute: ActivatedRoute,
3333
private structureService: NgdStructureService,
34-
private titleService: Title) {
34+
private titleService: Title,
35+
private metaTagsService: Meta) {
3536
}
3637

3738
get showSettings() {
@@ -70,7 +71,9 @@ export class NgdPageComponent implements OnInit, AfterContentChecked, OnDestroy
7071
}),
7172
filter(item => item),
7273
tap((item: any) => {
73-
this.titleService.setTitle(`UI Kitten - ${item.name}`);
74+
this.titleService.setTitle(`UI Kitten - ${item.title}`);
75+
this.metaTagsService.updateTag({ name: 'description', content: item.description });
76+
this.metaTagsService.updateTag({ name: 'keywords', content: item.keywords })
7477
}),
7578
publishReplay(),
7679
refCount(),

0 commit comments

Comments
 (0)