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,6 +13,12 @@ export const handler: Handlers = {
const query_by = url.searchParams.get("query_by") || "name,description";
let filter_by = "";
const type = url.searchParams.get("type");
if (type) {
filter_by = `type:=${type}`;
}
const typesenseClient = await getTypeSenseClient();
if (!typesenseClient) {
throw new Error("Query not available");
@ -23,7 +29,7 @@ export const handler: Handlers = {
.documents().search({
q: query,
query_by,
limit_hits: 100,
filter_by,
});
return json(searchResults.hits);

View File

@ -15,7 +15,7 @@ export const handler: Handlers<Article[] | null> = {
export default function Greet(props: PageProps<Article[] | null>) {
return (
<MainLayout url={props.url} title="Articles">
<MainLayout url={props.url} title="Articles" context={{ type: "article" }}>
<header class="flex gap-4 items-center mb-5 md:hidden">
<a
class="px-4 ml-4 py-2 bg-gray-300 text-gray-800 rounded-lg flex items-center gap-1"

View File

@ -15,7 +15,7 @@ export const handler: Handlers<Movie[] | null> = {
export default function Greet(props: PageProps<Movie[] | null>) {
return (
<MainLayout url={props.url} title="Movies">
<MainLayout url={props.url} title="Movies" context={{ type: "movie" }}>
<KMenu type="main" context={false} />
<header class="flex gap-4 items-center mb-5 md:hidden">
<a

View File

@ -14,7 +14,7 @@ export const handler: Handlers<Recipe[] | null> = {
export default function Greet(props: PageProps<Recipe[] | null>) {
return (
<MainLayout url={props.url} title="Recipes">
<MainLayout url={props.url} title="Recipes" context={{ type: "recipe" }}>
<header class="flex gap-4 items-center mb-2 lg:mb-5 md:hidden">
<a
class="px-4 lg:ml-4 py-2 bg-gray-300 text-gray-800 rounded-lg flex items-center gap-1"