UNPKG

@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! 🚀

231 lines (215 loc) 9.07 kB
import { _provideNgxMetaModuleManager, withOptions, _GLOBAL_APPLICATION_NAME, _withModuleManagerSameGlobalKey, _withModuleManagerNameAttribute, withNameAttribute, _GLOBAL_CANONICAL_URL, withManagerDeps, _headElementUpsertOrRemove, _urlResolver, _withModuleManagerSetterFactory, _maybeNonHttpUrlDevMessage, _isDefined, _GLOBAL_DESCRIPTION, withContentAttribute, _GLOBAL_LOCALE, _GLOBAL_TITLE, _titleFormatter } from '@davidlj95/ngx-meta/core'; import { DOCUMENT } from '@angular/common'; import * as i0 from '@angular/core'; import { VERSION, NgModule } from '@angular/core'; import { Title } from '@angular/platform-browser'; const provideStandardManager = (key, ...options) => _provideNgxMetaModuleManager(key, ['standard'], withOptions(...options)); /** * Manages the {@link Standard.applicationName} metadata * @public */ const provideStandardApplicationName = () => provideStandardManager(_GLOBAL_APPLICATION_NAME, _withModuleManagerSameGlobalKey(), _withModuleManagerNameAttribute(withNameAttribute('application-name'))); /** * {@inheritDoc provideStandardApplicationName} * @deprecated Use {@link provideStandardApplicationName} instead * @public */ const STANDARD_APPLICATION_NAME_METADATA_PROVIDER = /* @__PURE__ */ provideStandardApplicationName(); /** * Manages the {@link Standard.author} metadata * @public */ const provideStandardAuthor = () => provideStandardManager('author'); /** * {@inheritDoc provideStandardAuthor} * @deprecated Use {@link provideStandardAuthor} instead * @public */ const STANDARD_AUTHOR_METADATA_PROVIDER = /* @__PURE__ */ provideStandardAuthor(); const MODULE_NAME = 'standard'; /** * Manages the {@link Standard.canonicalUrl} metadata * @public */ const provideStandardCanonicalUrl = () => provideStandardManager(_GLOBAL_CANONICAL_URL, _withModuleManagerSameGlobalKey(), withManagerDeps(_headElementUpsertOrRemove(), DOCUMENT, _urlResolver()), _withModuleManagerSetterFactory((headElementUpsertOrRemove, doc, urlResolver) => (url) => { const resolvedUrl = urlResolver(url); /* istanbul ignore next https://github.com/istanbuljs/istanbuljs/issues/719 */ if (ngDevMode) { _maybeNonHttpUrlDevMessage(resolvedUrl, { module: MODULE_NAME, property: _GLOBAL_CANONICAL_URL, value: resolvedUrl, link: 'https://stackoverflow.com/a/8467966/3263250', shouldInsteadOfMust: true, }); } let linkElement; if (_isDefined(resolvedUrl)) { linkElement = doc.createElement(LINK_TAG); linkElement.setAttribute(REL_ATTR, CANONICAL_VAL); linkElement.setAttribute('href', resolvedUrl); } headElementUpsertOrRemove(SELECTOR, linkElement); })); const LINK_TAG = 'link'; const REL_ATTR = 'rel'; const CANONICAL_VAL = 'canonical'; const SELECTOR = `${LINK_TAG}[${REL_ATTR}='${CANONICAL_VAL}']`; /** * {@inheritDoc provideStandardCanonicalUrl} * @deprecated Use {@link provideStandardCanonicalUrl} instead * @public */ const STANDARD_CANONICAL_URL_METADATA_PROVIDER = /* @__PURE__ */ provideStandardCanonicalUrl(); /** * Manages the {@link Standard.description} metadata * @public */ const provideStandardDescription = () => provideStandardManager(_GLOBAL_DESCRIPTION, _withModuleManagerSameGlobalKey()); /** * {@inheritDoc provideStandardDescription} * @deprecated Use {@link provideStandardDescription} instead * @public */ const STANDARD_DESCRIPTION_METADATA_PROVIDER = /* @__PURE__ */ provideStandardDescription(); const KEY$1 = 'generator'; /** * Manages the {@link Standard.generator} metadata * @public */ const provideStandardGenerator = () => provideStandardManager(KEY$1, _withModuleManagerSetterFactory((metaElementsService) => (value) => metaElementsService.set(withNameAttribute(KEY$1), withContentAttribute(value === true ? `Angular v${VERSION.full}` : value)))); /** * {@inheritDoc provideStandardGenerator} * @deprecated Use {@link provideStandardGenerator} instead * @public */ const STANDARD_GENERATOR_METADATA_PROVIDER = /* @__PURE__ */ provideStandardGenerator(); const KEY = 'keywords'; /** * Manages the {@link Standard.keywords} metadata * @public */ const provideStandardKeywords = () => provideStandardManager(KEY, _withModuleManagerSetterFactory((metaElementsService) => (value) => metaElementsService.set(withNameAttribute(KEY), withContentAttribute(value?.join(','))))); /** * {@inheritDoc provideStandardKeywords} * @deprecated Use {@link provideStandardKeywords} instead * @public */ const STANDARD_KEYWORDS_METADATA_PROVIDER = /* @__PURE__ */ provideStandardKeywords(); const ATTRIBUTE_NAME = 'lang'; /** * Manages the {@link Standard.locale} metadata * @public */ const provideStandardLocale = () => provideStandardManager(_GLOBAL_LOCALE, _withModuleManagerSameGlobalKey(), withManagerDeps(DOCUMENT), _withModuleManagerSetterFactory((doc) => (locale) => { const htmlElement = doc.documentElement; if (!_isDefined(locale)) { htmlElement.removeAttribute(ATTRIBUTE_NAME); return; } htmlElement.setAttribute(ATTRIBUTE_NAME, locale); })); /** * {@inheritDoc provideStandardLocale} * @deprecated Use {@link provideStandardLocale} instead * @public */ const STANDARD_LOCALE_METADATA_PROVIDER = /* @__PURE__ */ provideStandardLocale(); /** * Manages the {@link Standard.themeColor} metadata * @public */ const provideStandardThemeColor = () => provideStandardManager('themeColor', _withModuleManagerSetterFactory((metaElementsService) => (value) => { const contents = !_isDefined(value) ? [] : Array.isArray(value) ? value : [{ color: value }]; metaElementsService.set(withNameAttribute('theme-color'), contents.map(({ color, media }) => withContentAttribute(color, media ? { media } : undefined))); })); /** * {@inheritDoc provideStandardThemeColor} * @deprecated Use {@link provideStandardThemeColor} instead * @public */ const STANDARD_THEME_COLOR_METADATA_PROVIDER = /* @__PURE__ */ provideStandardThemeColor(); /** * Manages the {@link Standard.title} metadata * @public */ const provideStandardTitle = () => provideStandardManager(_GLOBAL_TITLE, _withModuleManagerSameGlobalKey(), withManagerDeps(Title, _titleFormatter()), _withModuleManagerSetterFactory((titleService, titleFormatter) => (value) => { if (!_isDefined(value)) { return; } titleService.setTitle(titleFormatter(value)); })); /** * {@inheritDoc provideStandardTitle} * @deprecated Use {@link provideStandardTitle} instead * @public */ const STANDARD_TITLE_METADATA_PROVIDER = /* @__PURE__ */ provideStandardTitle(); /** * Provides {@link https://ngx-meta.dev/built-in-modules/standard/ | standard module} * metadata managers. * * @remarks * * This is the standalone, recommended API. Using this API is preferred. * However, you may also use {@link NgxMetaStandardModule} as the Angular module-based equivalent API. * * @public */ const provideNgxMetaStandard = () => [ provideStandardTitle(), provideStandardDescription(), provideStandardAuthor(), provideStandardKeywords(), provideStandardGenerator(), provideStandardApplicationName(), provideStandardCanonicalUrl(), provideStandardLocale(), provideStandardThemeColor(), ]; /** * Provides {@link https://ngx-meta.dev/built-in-modules/standard/ | standard module} * metadata managers. * * Check out {@link provideNgxMetaStandard} for the standalone, recommended API. * * @public */ class NgxMetaStandardModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxMetaStandardModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NgxMetaStandardModule }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxMetaStandardModule, providers: [provideNgxMetaStandard()] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxMetaStandardModule, decorators: [{ type: NgModule, args: [{ providers: [provideNgxMetaStandard()], }] }] }); /** * Generated bundle index. Do not edit. */ export { NgxMetaStandardModule, STANDARD_APPLICATION_NAME_METADATA_PROVIDER, STANDARD_AUTHOR_METADATA_PROVIDER, STANDARD_CANONICAL_URL_METADATA_PROVIDER, STANDARD_DESCRIPTION_METADATA_PROVIDER, STANDARD_GENERATOR_METADATA_PROVIDER, STANDARD_KEYWORDS_METADATA_PROVIDER, STANDARD_LOCALE_METADATA_PROVIDER, STANDARD_THEME_COLOR_METADATA_PROVIDER, STANDARD_TITLE_METADATA_PROVIDER, provideNgxMetaStandard, provideStandardApplicationName, provideStandardAuthor, provideStandardCanonicalUrl, provideStandardDescription, provideStandardGenerator, provideStandardKeywords, provideStandardLocale, provideStandardThemeColor, provideStandardTitle }; //# sourceMappingURL=davidlj95-ngx-meta-standard.mjs.map