2025-01-05 14:59:05 +01:00

38 lines
960 B
TypeScript

import { ComponentChildren } from "preact";
import { resources } from "@lib/resources.ts";
import { CSS, KATEX_CSS } from "gfm";
import { Head } from "$fresh/runtime.ts";
import Search, { RedirectSearchHandler } from "@islands/Search.tsx";
import { KMenu } from "@islands/KMenu.tsx";
import { Emoji } from "@components/Emoji.tsx";
import { SearchResult } from "@lib/types.ts";
export type Props = {
children: ComponentChildren;
title?: string;
name?: string;
url: URL;
description?: string;
context?: { type: string };
searchResults?: SearchResult;
};
export const MainLayout = (
{ children, url, title, context, searchResults }: Props,
) => {
const _url = typeof url === "string" ? new URL(url) : url;
const hasSearch = _url.search.includes("q=");
if (hasSearch) {
return (
<Search
q={_url.searchParams.get("q")}
{...context}
results={searchResults}
/>
);
}
return <>{children}</>;
};