@davidlj95/ngx-meta
Version:
Set your Angular site's metadata: standard meta tags, Open Graph, Twitter Cards, JSON-LD structured data and more. Supports SSR (and Angular Universal). Use a service. Use routes' data. Set it up in a flash! 🚀
68 lines (62 loc) • 2.68 kB
JavaScript
import { DOCUMENT } from '@angular/common';
import { provideNgxMetaManager, _isDefined, withOptions, withManagerDeps, _headElementUpsertOrRemove } from '@davidlj95/ngx-meta/core';
import * as i0 from '@angular/core';
import { NgModule } from '@angular/core';
const SCRIPT_TYPE = 'application/ld+json';
/**
* Manages the {@link JsonLdMetadata.jsonLd} metadata by placing it into the page's `<head>`
* @public
*/
const provideJsonLdInHead = () => provideNgxMetaManager('jsonLd', (headElementUpsertOrRemove, doc) => (jsonLd) => {
let scriptElement;
if (_isDefined(jsonLd)) {
scriptElement = doc.createElement('script');
scriptElement.setAttribute('type', SCRIPT_TYPE);
scriptElement.innerHTML = JSON.stringify(jsonLd);
}
headElementUpsertOrRemove(`script[type='${SCRIPT_TYPE}']`, scriptElement);
}, withOptions(withManagerDeps(_headElementUpsertOrRemove(), DOCUMENT)));
/**
* {@inheritDoc provideNgxMetaJsonLd}
* @deprecated Use {@link provideNgxMetaJsonLd} instead
* @public
*/
const JSON_LD_METADATA_PROVIDER =
/* @__PURE__ */
provideJsonLdInHead();
/**
* Provides {@link https://ngx-meta.dev/built-in-modules/json-ld/ | JSON-LD module}
* metadata managers.
*
* @remarks
*
* This is the standalone, recommended API. Using this API is preferred.
* However, you may also use {@link NgxMetaJsonLdModule} as the Angular module-based equivalent API.
*
* @public
*/
const provideNgxMetaJsonLd = () => provideJsonLdInHead();
/**
* Provides {@link https://ngx-meta.dev/built-in-modules/json-ld/ | JSON-LD module}
* metadata managers.
*
* Check out {@link provideNgxMetaJsonLd} for the standalone, recommended API.
*
* @public
*/
class NgxMetaJsonLdModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxMetaJsonLdModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NgxMetaJsonLdModule }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxMetaJsonLdModule, providers: [provideNgxMetaJsonLd()] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxMetaJsonLdModule, decorators: [{
type: NgModule,
args: [{
providers: [provideNgxMetaJsonLd()],
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { JSON_LD_METADATA_PROVIDER, NgxMetaJsonLdModule, provideNgxMetaJsonLd };
//# sourceMappingURL=davidlj95-ngx-meta-json-ld.mjs.map