2023-07-26 13:47:01 +02:00
|
|
|
import { Handlers, PageProps } from "$fresh/server.ts";
|
2023-07-27 15:28:50 +02:00
|
|
|
import { IngredientsList } from "@components/IngredientsList.tsx";
|
|
|
|
import { RecipeHero } from "@components/RecipeHero.tsx";
|
|
|
|
import { MainLayout } from "@components/layouts/main.tsx";
|
|
|
|
import { Recipe } from "@lib/recipes.ts";
|
2023-07-26 13:47:01 +02:00
|
|
|
import { getRecipe } from "../api/recipes/[name].ts";
|
|
|
|
|
|
|
|
export const handler: Handlers<Recipe | null> = {
|
|
|
|
async GET(_, ctx) {
|
|
|
|
const recipe = await getRecipe(ctx.params.name);
|
|
|
|
return ctx.render(recipe);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function Greet(props: PageProps<Recipe>) {
|
|
|
|
return (
|
|
|
|
<MainLayout>
|
|
|
|
<RecipeHero recipe={props.data} />
|
2023-07-26 15:48:03 +02:00
|
|
|
<div class="px-8 text-white mt-10">
|
|
|
|
<h3 class="text-3xl my-5">Ingredients</h3>
|
2023-07-26 13:47:01 +02:00
|
|
|
<IngredientsList ingredients={props.data.ingredients} />
|
2023-07-26 15:48:03 +02:00
|
|
|
<h3 class="text-3xl my-5">Preparation</h3>
|
2023-07-26 13:47:01 +02:00
|
|
|
</div>
|
|
|
|
</MainLayout>
|
|
|
|
);
|
|
|
|
}
|