stackpress
Version:
Incept is a content management framework.
27 lines (26 loc) • 876 B
JavaScript
import path from 'node:path';
import { fileURLToPath } from 'node:url';
export default function plugin(ctx) {
ctx.on('config', async (_req, _res, ctx) => {
if (!ctx.config.has('client'))
return;
const module = ctx.config.path('client.module', 'stackpress-client');
try {
const client = await ctx.loader.import(module);
ctx.register('client', client);
}
catch (e) { }
}, 10);
ctx.on('idea', async (req) => {
const transformer = req.data('transformer');
const schema = await transformer.schema();
if (!schema.plugin) {
schema.plugin = {};
}
const dirname = typeof __dirname === 'undefined'
? path.dirname(fileURLToPath(import.meta.url))
: __dirname;
schema.plugin[`${dirname}/transform`] = {};
});
}
;