Reviewers: #reviewers Subscribers: jenkins-user Differential Revision: https://hub.sealcode.org/D1452
21 lines
657 B
TypeScript
21 lines
657 B
TypeScript
import type { BaseContext } from "koa";
|
|
import type { JDDContext } from "@sealcode/jdd";
|
|
import type { FilePointer } from "@sealcode/file-manager";
|
|
import { makeSimpleJDDContext } from "@sealcode/jdd";
|
|
import { TheFileManager } from "./file-manager.js";
|
|
import { imageRouter } from "./image-router.js";
|
|
|
|
export function makeJDDContext(ctx: BaseContext): JDDContext {
|
|
return {
|
|
...makeSimpleJDDContext(TheFileManager),
|
|
render_image: async (image: string | FilePointer | null, args) => {
|
|
if (!image) {
|
|
return "";
|
|
}
|
|
const file = await TheFileManager.toPointer(image);
|
|
return imageRouter.image(await file.getPath(), args);
|
|
},
|
|
ctx,
|
|
};
|
|
}
|