import { Templatable, tempstream } from "tempstream";
import { Readable } from "stream";
import { BaseContext } from "koa";
import navbar from "./routes/common/navbar";
export const defaultHead = (ctx: BaseContext, title: string) => /* HTML */ `
${title} ยท ${ctx.$app.manifest.name}
`;
export default function html(
ctx: BaseContext,
title: string,
body: Templatable,
makeHead: (ctx: BaseContext, title: string) => Templatable = defaultHead
): Readable {
ctx.set("content-type", "text/html;charset=utf-8");
return tempstream/* HTML */ `
${makeHead(ctx, title)}
${navbar(ctx)} ${body}
`;
}