import { render } from "preact-render-to-string"; import { VNode } from "preact"; /** * Renders JSX to an HTML Response with proper headers * @param jsx - The JSX element to render * @param options - Optional response configuration * @returns A Response object with rendered HTML */ export function renderHTML( jsx: VNode, options?: { status?: number; headers?: Record; title?: string; description?: string; }, ): Response { const html = render(jsx); const headers: Record = { "content-type": "text/html; charset=utf-8", ...options?.headers, }; return new Response(`${html}`, { status: options?.status || 200, headers, }); }