UNPKG

stackpress

Version:

Incept is a content management framework.

42 lines (41 loc) 1.92 kB
"use strict"; 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()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = plugin; const node_path_1 = __importDefault(require("node:path")); const node_url_1 = require("node:url"); function plugin(ctx) { ctx.on('config', (_req, _res, ctx) => __awaiter(this, void 0, void 0, function* () { if (!ctx.config.has('client')) return; const module = ctx.config.path('client.module', 'stackpress-client'); try { const client = yield ctx.loader.import(module); ctx.register('client', client); } catch (e) { } }), 10); ctx.on('idea', (req) => __awaiter(this, void 0, void 0, function* () { const transformer = req.data('transformer'); const schema = yield transformer.schema(); if (!schema.plugin) { schema.plugin = {}; } const dirname = typeof __dirname === 'undefined' ? node_path_1.default.dirname((0, node_url_1.fileURLToPath)(import.meta.url)) : __dirname; schema.plugin[`${dirname}/transform`] = {}; })); } ;