/** * Dependency-free Open Graph image generation. * * **The default SVG output does not work as a social card.** X, Facebook, LinkedIn, Slack, Discord * and iMessage all refuse `image/svg+xml` for `og:image` and render nothing - the link preview is * blank, and it is blank silently, which is the failure mode this package exists to prevent * elsewhere. Serving SVG is only useful where you control the consumer: an internal dashboard, a * docs thumbnail, a preview route you look at yourself. * * **For a card a crawler will actually render, pass `rasterizer`.** It receives the SVG and returns * PNG/JPEG/WebP bytes - a Satori + Resvg pair is the usual choice. Keeping it injected rather than * bundled is what keeps a WASM rasterizer out of `@nifrajs/image` and out of every browser bundle * that imports this package for something else. * * ```ts * import { ogImageResponse } from "@nifrajs/image/og" * * // Renders on X, Facebook, LinkedIn, Slack. * export const GET = (request: Request) => * ogImageResponse({ title: "Ship it", rasterizer: pngRasterizer }, request) * ``` */ export interface OgImageRasterized { readonly bytes: Uint8Array; readonly contentType: string; } export type OgImageRasterizer = (svg: string) => OgImageRasterized | Promise; export interface OgImageOptions { readonly title: string; readonly description?: string; readonly eyebrow?: string; readonly width?: number; readonly height?: number; readonly background?: string; readonly foreground?: string; readonly accent?: string; /** Optional PNG/JPEG/WebP backend. Omit to serve the generated SVG. */ readonly rasterizer?: OgImageRasterizer; /** Browser/cache freshness in seconds. Default one year. */ readonly cacheMaxAge?: number; /** Maximum bytes accepted from an injected rasterizer. Default 10 MiB. */ readonly maxBytes?: number; } /** Render a bounded, deterministic SVG suitable for an `og:image` endpoint. */ export declare function renderOgImage(options: OgImageOptions): string; /** * Build a cacheable OG image response. GET and HEAD are supported; conditional requests short-circuit * rasterization, so a crawler revalidation never repeats expensive codec work. */ export declare function ogImageResponse(options: OgImageOptions, request?: Request): Promise; //# sourceMappingURL=og.d.ts.map