@rr0/cms
Version:
RR0 Content Management System (CMS)
54 lines (53 loc) • 2.07 kB
TypeScript
import { ReplaceCommand } from "ssg-api";
import { HtmlRR0Context } from "./RR0Context.js";
import { Canvas, CanvasRenderingContext2D } from "canvas";
import { TimeService, TimeTextBuilder } from "./time/index.js";
/**
* Create a preview image for each page sharing.
*/
export declare class OpenGraphCommand implements ReplaceCommand<HtmlRR0Context> {
protected outDir: string;
protected timeFiles: string[];
protected baseUrl: string;
protected timeService: TimeService;
readonly timeTextBuilder: TimeTextBuilder;
protected width: number;
protected height: number;
protected num: number;
constructor(outDir: string, timeFiles: string[], baseUrl: string, timeService: TimeService, timeTextBuilder: TimeTextBuilder, width?: number, height?: number);
execute(context: HtmlRR0Context): Promise<void>;
getInfoStr(context: HtmlRR0Context): string;
contentStepEnd(): Promise<void>;
/**
* Draw text on the canvas, with line returns when required.
*
* @param canvasCtx
* @param text The text to write.
* @param margin
* @param lineHeight
* @param font
* @protected
*/
protected drawText(canvasCtx: CanvasRenderingContext2D, text: string, margin: number, lineHeight: number, font: string): void;
/**
* Draw a left-to-right gradient from white to transparent.
*
* @param canvasCtx
* @param widthRatio
* @param startColor
* @param endColor
* @private
*/
protected drawGradient(canvasCtx: CanvasRenderingContext2D, widthRatio: number, startColor?: string, endColor?: string): void;
readonly supportedFiles = "img[src$='.png'],img[src$='.jpg'],img[src$='.gif']";
/**
* Draw a height-scaled image on the right of the canvas.
*
* @param context
* @param canvasCtx
* @param dy
* @protected
*/
protected drawImage(context: HtmlRR0Context, canvasCtx: CanvasRenderingContext2D, dy?: number): Promise<number>;
protected writeImageFile(context: HtmlRR0Context, canvas: Canvas): string;
}