import { ComponentChildren } from "preact";
import { menu } from "@lib/menus.ts";
import { CSS, KATEX_CSS, render } from "https://deno.land/x/gfm/mod.ts";
import { Head } from "$fresh/runtime.ts";

export type Props = {
  children: ComponentChildren;
  title?: string;
  name?: string;
  url: URL;
  description?: string;
};

export const MainLayout = ({ children, url, title }: Props) => {
  return (
    <div
      class="md:grid mx-auto"
      style={{ gridTemplateColumns: "200px 1fr", maxWidth: "1024px" }}
    >
      <Head>
        <style>{CSS}</style>
        <style>{KATEX_CSS}</style>
        {title &&
          <title>{title}</title>}
      </Head>
      <aside class="p-4 hidden md:block">
        <nav class="min-h-fit rounded-3xl p-3 grid gap-3 fixed t-0">
          {menu.map((m) => {
            return (
              <a
                href={m.link}
                class={`block ${
                  m.link === url.pathname ? "bg-white text-black" : "text-white"
                } p-3 text-xl w-full rounded-2xl`}
              >
                {m.name}
              </a>
            );
          })}
        </nav>
      </aside>
      <main
        class="py-5"
        style={{ fontFamily: "Work Sans" }}
      >
        {children}
      </main>
    </div>
  );
};
