feat: render search on server
This commit is contained in:
@ -5,6 +5,7 @@ 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;
|
||||
@ -13,9 +14,12 @@ export type Props = {
|
||||
url: URL;
|
||||
description?: string;
|
||||
context?: { type: string };
|
||||
searchResults?: SearchResult;
|
||||
};
|
||||
|
||||
export const MainLayout = ({ children, url, title, context }: Props) => {
|
||||
export const MainLayout = (
|
||||
{ children, url, title, context, searchResults }: Props,
|
||||
) => {
|
||||
const hasSearch = url.search.includes("q=");
|
||||
|
||||
return (
|
||||
@ -49,7 +53,13 @@ export const MainLayout = ({ children, url, title, context }: Props) => {
|
||||
class="py-5"
|
||||
style={{ fontFamily: "Work Sans" }}
|
||||
>
|
||||
{hasSearch && <Search q={url.searchParams.get("q")} {...context} />}
|
||||
{hasSearch && (
|
||||
<Search
|
||||
q={url.searchParams.get("q")}
|
||||
{...context}
|
||||
results={searchResults}
|
||||
/>
|
||||
)}
|
||||
{!hasSearch && children}
|
||||
</main>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user