///
import { React, jsx } from "./deps.ts";
import config from "./config.ts";
class StringReader implements Deno.Reader {
private data: Uint8Array;
private offset = 0;
constructor(text: string) {
this.data = new TextEncoder().encode(text);
}
async read(p: Uint8Array): Promise {
if (this.offset >= this.data.byteLength) return null;
const forLength = Math.min(p.length, this.data.length - this.offset);
for (let i = 0; i < forLength; i++) {
p[i] = this.data[i + this.offset];
}
this.offset += forLength;
return forLength;
}
}
export default async function render(
name: string,
data: any
): Promise {
console.log(config);
const component: {
default: () => JSX.IntrinsicElements | Promise;
} = await import(`./views/${name}.tsx`);
const res = await ().render();
return new StringReader(res as string);
}