feat: initial refactor to use marka as backend
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { getAllRecipes, Recipe } from "@lib/resource/recipes.ts";
|
||||
import { Recipe } from "@lib/recipeSchema.ts";
|
||||
import { Grid } from "@components/Grid.tsx";
|
||||
import { IconArrowLeft } from "@components/icons.tsx";
|
||||
import { KMenu } from "@islands/KMenu.tsx";
|
||||
import { RedirectSearchHandler } from "@islands/Search.tsx";
|
||||
import { parseResourceUrl, searchResource } from "@lib/search.ts";
|
||||
import { GenericResource } from "@lib/types.ts";
|
||||
import { ResourceCard } from "@components/Card.tsx";
|
||||
import { fetchResource } from "@lib/resources.ts";
|
||||
import { parseResourceUrl, searchResource } from "@lib/search.ts";
|
||||
|
||||
export const handler: Handlers<
|
||||
{ recipes: Recipe[] | null; searchResults?: GenericResource[] }
|
||||
> = {
|
||||
async GET(req, ctx) {
|
||||
const recipes = await getAllRecipes();
|
||||
const { content: recipes } = await fetchResource("recipes");
|
||||
const searchParams = parseResourceUrl(req.url);
|
||||
const searchResults = searchParams &&
|
||||
await searchResource({ ...searchParams, types: ["recipe"] });
|
||||
@@ -48,8 +49,8 @@ export default function Greet(
|
||||
<h3 class="text-2xl text-white font-light">🍽️ Recipes</h3>
|
||||
</header>
|
||||
<Grid>
|
||||
{recipes?.map((doc) => {
|
||||
return <ResourceCard sublink="recipes" res={doc} />;
|
||||
{recipes?.filter((s) => !!s?.content?.name).map((doc) => {
|
||||
return <ResourceCard sublink="recipes" key={doc.name} res={doc} />;
|
||||
})}
|
||||
</Grid>
|
||||
</MainLayout>
|
||||
|
||||
Reference in New Issue
Block a user