support async components

This commit is contained in:
Chris Wanstrath 2025-10-08 13:15:52 -07:00
parent d5e0dbd2db
commit e35aef35cd

View File

@ -79,13 +79,13 @@ async function loadApp(path: string): Promise<App | undefined> {
return mod.default as App
}
export function toResponse(source: string | Child | Response): Response {
export async function toResponse(source: string | Child | Response): Promise<Response> {
if (source instanceof Response)
return source
else if (typeof source === "string")
return new Response(source)
else
return new Response(renderToString(source), {
return new Response(await source?.toString(), {
headers: {
"Content-Type": "text/html; charset=utf-8"
}