diff --git a/src/back/html.ts b/src/back/html.ts index 2c8c77e..bb2d07e 100644 --- a/src/back/html.ts +++ b/src/back/html.ts @@ -4,12 +4,24 @@ import { BaseContext } from "koa"; import { default as default_navbar } from "./routes/common/navbar.js"; import { toKebabCase } from "js-convert-case"; -export const defaultHead = (ctx: BaseContext, title: string) => /* HTML */ ` - ${title} · ${ctx.$app.manifest.name} - +export const defaultHead = ( + ctx: BaseContext, + title: string, + options: HTMLOptions +) => /* HTML */ `${title} · ${ctx.$app.manifest.name} - `; + + ${options.morphing ? `` : ""} + ${options.preserveScroll + ? `` + : ""}`; export type HTMLOptions = { preserveScroll?: boolean; @@ -22,22 +34,22 @@ export default function html( ctx: BaseContext, title: string, body: Templatable, - { preserveScroll, morphing, navbar, autoRefreshCSS }: HTMLOptions = {}, - makeHead: (ctx: BaseContext, title: string) => Templatable = defaultHead + htmlOptions: HTMLOptions = {}, + makeHead: ( + ctx: BaseContext, + title: string, + options: HTMLOptions + ) => Templatable = defaultHead ): Readable { ctx.set("content-type", "text/html;charset=utf-8"); return tempstream/* HTML */ ` - ${makeHead(ctx, title)} - ${morphing ? `` : ""} - ${preserveScroll - ? `` - : ""} + ${makeHead(ctx, title, htmlOptions)} - ${(navbar || default_navbar)(ctx)} ${body} - ${autoRefreshCSS + ${(htmlOptions.navbar || default_navbar)(ctx)} ${body} + ${htmlOptions.autoRefreshCSS ? /* HTML */ `` : ""}