Files
memorium/components/layouts/main.tsx
2025-11-04 12:58:26 +01:00

33 lines
733 B
TypeScript

import { ComponentChildren } from "preact";
import Search from "@islands/Search.tsx";
import { GenericResource } from "@lib/marka/schema.ts";
export type Props = {
children: ComponentChildren;
title?: string;
name?: string;
url: URL | string;
description?: string;
context?: { type: string };
searchResults?: GenericResource[];
};
export const MainLayout = (
{ children, url, 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;
};