1import { readFileSync } from "node:fs";2import { join } from "node:path";3import type { Hono } from "hono";4import { describeFile } from "../describe/describe.ts";5import { html } from "./html.ts";6import { cacheFor, type PageContext, page } from "./layout.ts";7import { renderParagraph, renderSiteMarkdown } from "./markdown.ts";89const SITE_DIR = join(import.meta.dir, "../../docs/site");101112export function registerDocsPages(app: Hono, ctx: PageContext): void {13 for (const name of ["docs", "support"]) {14 const source = readFileSync(join(SITE_DIR, `${name}.md`), "utf8");15 const intro = describeFile(`${name}.md`, source);16 const description = intro ? renderParagraph(intro, { repo: "", dir: "", at: null }).text : "";17 const body = html`<article class="site-doc markdown">${renderSiteMarkdown(source)}</article>`;18 app.get(`/${name}`, (c) => {19 cacheFor(c, false);20 return c.html(page(ctx, { title: name, description, path: `/${name}`, body }));21 });22 }23}