feat: add search menu to all resources

This commit is contained in:
2023-08-06 00:33:06 +02:00
parent 32a7f89309
commit 0e0d26c939
12 changed files with 208 additions and 8 deletions

View File

@ -13,3 +13,4 @@ export { default as IconCircleMinus } from "https://deno.land/x/tabler_icons_tsx
export { default as IconLoader2 } from "https://deno.land/x/tabler_icons_tsx@0.0.3/tsx/loader-2.tsx";
export { default as IconLogin } from "https://deno.land/x/tabler_icons_tsx@0.0.3/tsx/login.tsx";
export { default as IconLogout } from "https://deno.land/x/tabler_icons_tsx@0.0.3/tsx/logout.tsx";
export { default as IconSearch } from "https://deno.land/x/tabler_icons_tsx@0.0.3/tsx/search.tsx";

View File

@ -1,7 +1,8 @@
import { ComponentChildren } from "preact";
import { menu } from "@lib/menus.ts";
import { CSS, KATEX_CSS, render } from "https://deno.land/x/gfm/mod.ts";
import { CSS, KATEX_CSS } from "https://deno.land/x/gfm@0.2.5/mod.ts";
import { Head } from "$fresh/runtime.ts";
import Search, { RedirectSearchHandler } from "@islands/Search.tsx";
export type Props = {
children: ComponentChildren;
@ -9,9 +10,12 @@ export type Props = {
name?: string;
url: URL;
description?: string;
context?: { type: string };
};
export const MainLayout = ({ children, url, title }: Props) => {
export const MainLayout = ({ children, url, title, context }: Props) => {
const hasSearch = url.search.includes("q=");
return (
<div
class="md:grid mx-auto"
@ -39,11 +43,13 @@ export const MainLayout = ({ children, url, title }: Props) => {
})}
</nav>
</aside>
<RedirectSearchHandler />
<main
class="py-5"
style={{ fontFamily: "Work Sans" }}
>
{children}
{hasSearch && <Search q={url.searchParams.get("q")} {...context} />}
{!hasSearch && children}
</main>
</div>
);