UNPKG

ng-simple-seo

Version:

A very light weight seo mechanism that adds all the necessary meta tags to your Angular Application 🚊

176 lines (169 loc) 7.03 kB
import { __decorate, __metadata } from 'tslib'; import { ɵɵdefineInjectable, ɵɵinject, Injectable, Input, Component, NgModule } from '@angular/core'; import { Title, Meta } from '@angular/platform-browser'; var NgSimpleSeoService = /** @class */ (function () { function NgSimpleSeoService( // Application Services title, meta) { this.title = title; this.meta = meta; } NgSimpleSeoService.prototype.set = function (title, keywords, description, twitterTitle, twitterDescription, twitterImage, twitterSite, twitterCreator, ogTitle, ogType, ogDescription, ogImage, ogUrl, ogSitename) { this.title.setTitle("" + title); this.meta.updateTag({ name: 'robots', content: 'index, follow' }); if (description !== undefined) { this.meta.updateTag({ name: 'description', content: description }); } if (keywords !== undefined) { this.meta.updateTag({ name: 'keywords', content: keywords }); } if (twitterTitle !== undefined) { this.meta.updateTag({ name: 'twitter:title', content: twitterTitle }); } if (twitterDescription !== undefined) { this.meta.updateTag({ name: 'twitter:description', content: twitterDescription }); } if (twitterImage !== undefined) { this.meta.updateTag({ name: 'twitter:image', content: twitterImage }); } if (twitterSite !== undefined) { this.meta.updateTag({ name: 'twitter:site', content: twitterSite }); } if (twitterCreator !== undefined) { this.meta.updateTag({ name: 'twitter:creator', content: twitterCreator }); } if (ogTitle !== undefined) { this.meta.updateTag({ name: 'og:title', content: ogTitle }); } if (ogType !== undefined) { this.meta.updateTag({ name: 'og:type', content: ogType }); } if (ogDescription !== undefined) { this.meta.updateTag({ name: 'og:description', content: ogDescription }); } if (ogImage !== undefined) { this.meta.updateTag({ name: 'og:image', content: ogImage }); } if (ogUrl !== undefined) { this.meta.updateTag({ name: 'og:url', content: ogUrl }); } if (ogSitename !== undefined) { this.meta.updateTag({ name: 'og:site_name', content: ogSitename }); } }; NgSimpleSeoService.ctorParameters = function () { return [ { type: Title }, { type: Meta } ]; }; NgSimpleSeoService.ɵprov = ɵɵdefineInjectable({ factory: function NgSimpleSeoService_Factory() { return new NgSimpleSeoService(ɵɵinject(Title), ɵɵinject(Meta)); }, token: NgSimpleSeoService, providedIn: "root" }); NgSimpleSeoService = __decorate([ Injectable({ providedIn: 'root', }), __metadata("design:paramtypes", [Title, Meta]) ], NgSimpleSeoService); return NgSimpleSeoService; }()); var NgSimpleSeoComponent = /** @class */ (function () { function NgSimpleSeoComponent(ngSimpleSeoService) { this.ngSimpleSeoService = ngSimpleSeoService; this.title = 'Angular Application'; } NgSimpleSeoComponent.prototype.ngOnChanges = function (changes) { if (changes) { this.ngSimpleSeoService.set(this.title, this.keywords, this.description, this.twitterTitle, this.twitterDescription, this.twitterImage, this.twitterSite, this.twitterCreator, this.ogTitle, this.ogType, this.ogDescription, this.ogImage, this.ogUrl, this.ogSitename); } }; NgSimpleSeoComponent.prototype.ngOnInit = function () { this.ngSimpleSeoService.set(this.title, this.keywords, this.description, this.twitterTitle, this.twitterDescription, this.twitterImage, this.twitterSite, this.twitterCreator, this.ogTitle, this.ogType, this.ogDescription, this.ogImage, this.ogUrl, this.ogSitename); }; NgSimpleSeoComponent.ctorParameters = function () { return [ { type: NgSimpleSeoService } ]; }; __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "description", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "keywords", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "twitterTitle", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "twitterDescription", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "twitterImage", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "twitterSite", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "twitterCreator", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "ogTitle", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "ogType", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "ogDescription", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "ogImage", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "ogUrl", void 0); __decorate([ Input(), __metadata("design:type", Object) ], NgSimpleSeoComponent.prototype, "ogSitename", void 0); NgSimpleSeoComponent = __decorate([ Component({ selector: "ng-simple-seo", template: "" }), __metadata("design:paramtypes", [NgSimpleSeoService]) ], NgSimpleSeoComponent); return NgSimpleSeoComponent; }()); var NgSimpleSeoModule = /** @class */ (function () { function NgSimpleSeoModule() { } NgSimpleSeoModule = __decorate([ NgModule({ providers: [NgSimpleSeoService], declarations: [NgSimpleSeoComponent], imports: [], exports: [NgSimpleSeoComponent], }) ], NgSimpleSeoModule); return NgSimpleSeoModule; }()); /* * Public API Surface of ng-simple-seo */ /** * Generated bundle index. Do not edit. */ export { NgSimpleSeoComponent, NgSimpleSeoModule, NgSimpleSeoService }; //# sourceMappingURL=ng-simple-seo.js.map