import { asset, Head } from "$fresh/runtime.ts"; import { Handlers, PageProps } from "$fresh/server.ts"; import { frontMatter, gfm } from "../../utils/markdown.ts"; import Header from "../../components/Header.tsx"; import DocsTitle from "../../components/DocsTitle.tsx"; import DocsSidebar from "../../components/DocsSidebar.tsx"; import Footer from "../../components/Footer.tsx"; import { SLUGS, TABLE_OF_CONTENTS, TableOfContentsEntry, } from "../../data/docs.ts"; interface Data { page: Page; } interface Page extends TableOfContentsEntry { markdown: string; data: Record; } export const handler: Handlers = { async GET(_req, ctx) { const slug = ctx.params.slug; if (slug === "") { return new Response("", { status: 307, headers: { location: "/docs/introduction" }, }); } if (slug === "concepts/architechture") { return new Response("", { status: 307, headers: { location: "/docs/concepts/architecture" }, }); } const entry = TABLE_OF_CONTENTS[slug]; if (!entry) { return ctx.renderNotFound(); } const url = new URL(`../../../${entry.file}`, import.meta.url); const fileContent = await Deno.readTextFile(url); const { body, attrs } = frontMatter>(fileContent); const page = { ...entry, markdown: body, data: attrs ?? {} }; const resp = ctx.render({ page }); return resp; }, }; export default function DocsPage(props: PageProps) { const ogImageUrl = new URL(asset("/home-og.png"), props.url).href; const title = `${props.data.page?.title ?? "Not Found"} | fresh docs`; let description = "Fresh Document"; if (props.data.page.data.description) { description = String(props.data.page.data.description); } return ( <> {title}
); } function Main(props: { path: string; page: Page }) { return (
); } function MobileSidebar(props: { path: string }) { return ( <> ); } function DesktopSidebar(props: { path: string }) { return ( ); } function Content(props: { page: Page }) { const html = gfm.render(props.page.markdown); return (

{props.page.title}

); } const button = "p-2 bg-gray-100 w-full border(1 gray-200) grid"; function ForwardBackButtons(props: { slug: string }) { const currentIndex = SLUGS.findIndex((slug) => slug === props.slug); const previousSlug = SLUGS[currentIndex - 1]; const nextSlug = SLUGS[currentIndex + 1]; const previous = TABLE_OF_CONTENTS[previousSlug]; const next = TABLE_OF_CONTENTS[nextSlug]; const upper = "text(sm gray-600)"; const category = "font-normal"; const lower = "text-gray-900 font-medium"; return ( ); }