26 lines
776 B
TypeScript
26 lines
776 B
TypeScript
import { Handlers, PageProps } from "$fresh/server.ts";
|
|
import { RecipeCard } from "@components/RecipeCard.tsx";
|
|
import { MainLayout } from "@components/layouts/main.tsx";
|
|
import type { Document } from "@lib/documents.ts";
|
|
import { Recipe } from "@lib/recipes.ts";
|
|
import { getRecipes } from "../api/recipes/index.ts";
|
|
|
|
export const handler: Handlers<Recipe[] | null> = {
|
|
async GET(_, ctx) {
|
|
const recipes = await getRecipes();
|
|
return ctx.render(recipes);
|
|
},
|
|
};
|
|
|
|
export default function Greet(props: PageProps<Recipe[] | null>) {
|
|
return (
|
|
<MainLayout>
|
|
<div class="flex flex-wrap justify-center items-center gap-4 px-4">
|
|
{props.data?.map((doc) => {
|
|
return <RecipeCard recipe={doc} />;
|
|
})}
|
|
</div>
|
|
</MainLayout>
|
|
);
|
|
}
|