38 lines
960 B
TypeScript
Raw Normal View History

2023-07-26 13:47:01 +02:00
import { ComponentChildren } from "preact";
2023-08-06 17:47:26 +02:00
import { resources } from "@lib/resources.ts";
2025-01-05 14:59:05 +01:00
import { CSS, KATEX_CSS } from "gfm";
import { Head } from "$fresh/runtime.ts";
2023-08-06 00:33:06 +02:00
import Search, { RedirectSearchHandler } from "@islands/Search.tsx";
2023-08-06 18:06:09 +02:00
import { KMenu } from "@islands/KMenu.tsx";
2023-08-09 15:20:14 +02:00
import { Emoji } from "@components/Emoji.tsx";
2023-08-10 16:59:18 +02:00
import { SearchResult } from "@lib/types.ts";
2023-07-26 13:47:01 +02:00
export type Props = {
children: ComponentChildren;
title?: string;
name?: string;
2023-07-30 21:43:09 +02:00
url: URL;
2023-07-26 13:47:01 +02:00
description?: string;
2023-08-06 00:33:06 +02:00
context?: { type: string };
2023-08-10 16:59:18 +02:00
searchResults?: SearchResult;
2023-07-26 13:47:01 +02:00
};
2023-08-10 16:59:18 +02:00
export const MainLayout = (
{ children, url, title, context, searchResults }: Props,
) => {
2023-09-08 13:33:29 +02:00
const _url = typeof url === "string" ? new URL(url) : url;
const hasSearch = _url.search.includes("q=");
2023-08-06 00:33:06 +02:00
2023-09-08 13:33:29 +02:00
if (hasSearch) {
return (
<Search
q={_url.searchParams.get("q")}
{...context}
results={searchResults}
/>
);
}
return <>{children}</>;
2023-07-26 13:47:01 +02:00
};