/** @jsx h */ /** @jsxFrag Fragment */ import { apply, Fragment, h, Head, PageProps, tw } from "../../client_deps.ts"; import { gfm, Handlers } from "../../server_deps.ts"; import DocsSidebar from "../../components/DocsSidebar.tsx"; import Footer from "../../components/Footer.tsx"; import NavigationBar from "../../components/NavigationBar.tsx"; import WarningBanner from "../../components/WarningBanner.tsx"; import { SLUGS, TABLE_OF_CONTENTS, TableOfContentsEntry, } from "../../data/docs.ts"; interface Data { page: Page; } interface Page extends TableOfContentsEntry { markdown: string; } export const handler: Handlers = { async GET(_req, ctx) { const slug = ctx.params.slug; if (slug === "") { return new Response("", { status: 307, headers: { location: "/docs/introduction" }, }); } const entry = TABLE_OF_CONTENTS[slug]; if (!entry) { return new Response("404 Page not found", { status: 404, }); } const url = new URL(`../../../${entry.file}`, import.meta.url); const markdown = await Deno.readTextFile(url); const page = { ...entry, markdown }; const resp = ctx.render({ page }); return resp; }, }; export default function DocsPage(props: PageProps) { return ( <> {props.data.page?.title ?? "Not Found"} | fresh docs