@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! 🚀
49 lines • 2.8 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ngAdd = ngAdd;
const schematics_1 = require("@angular-devkit/schematics");
const add_root_provider_1 = require("./add-root-provider");
// noinspection JSUnusedGlobalSymbols (actually used in `collection.json`)
function ngAdd(options) {
return (_tree, context) => __awaiter(this, void 0, void 0, function* () {
const addRootProvider = yield (0, add_root_provider_1.makeAddRootProviderFn)();
if (!addRootProvider) {
// Standalone schematic utils are only available for v16.1 and above.
// https://github.com/angular/angular-cli/commit/b14b959901d5a670da0df45e082b8fd4c3392d14
context.logger.warn([
'ngx-meta `ng add` schematics only work for Angular v16.1 and above, sorry :(',
"Please, setup the library manually. Don't worry, it's just a few lines around :)",
'You can find a guide at: https://ngx-meta.dev/guides/manual-setup/',
].join('\n'));
logLibraryInfo(context.logger);
return;
}
const addRootProviderToProject = (name) => addRootProvider({ name, project: options.project });
return (0, schematics_1.chain)([
addRootProviderToProject('core'),
options.routing ? addRootProviderToProject('routing') : (0, schematics_1.noop)(),
...options.metadataModules.map((metadataModule) => addRootProviderToProject(metadataModule)),
() => {
context.logger.info('ngx-meta library was successfully set up 🚀');
logLibraryInfo(context.logger);
},
]);
});
}
const logLibraryInfo = (logger) => logger.info([
'For more information, you can check out:',
' - Documentation: https://ngx-meta.dev',
' - Repository: https://github.com/davidlj95/ngx',
' - NPM: https://www.npmjs.com/package/@davidlj95/ngx-meta',
'If you enjoyed using the library, please star its GitHub repository! ⭐️❤️',
].join('\n'));
//# sourceMappingURL=index.js.map
;