feat: show rating

This commit is contained in:
2023-07-30 19:40:39 +02:00
parent c7279105ca
commit 0632ae05c1
12 changed files with 172 additions and 88 deletions

View File

@ -10,6 +10,7 @@ import * as cache from "@lib/cache/image.ts";
await initializeImageMagick();
async function getRemoteImage(image: string) {
console.log("[api/image] fetching", { image });
const sourceRes = await fetch(image);
if (!sourceRes.ok) {
return "Error retrieving image from URL.";
@ -131,8 +132,6 @@ export const handler = async (
mediaType: remoteImage.mediaType,
});
console.log("[api/image] stored image in cache");
return new Response(modifiedImage, {
headers: {
"Content-Type": remoteImage.mediaType,

View File

@ -1,9 +1,11 @@
import { Handlers, PageProps } from "$fresh/server.ts";
import { IngredientsList } from "@components/IngredientsList.tsx";
import { IngredientsList } from "@islands/IngredientsList.tsx";
import { RecipeHero } from "@components/RecipeHero.tsx";
import { MainLayout } from "@components/layouts/main.tsx";
import { Recipe } from "@lib/recipes.ts";
import { getRecipe } from "../api/recipes/[name].ts";
import Counter from "@islands/Counter.tsx";
import { useSignal } from "@preact/signals";
export const handler: Handlers<Recipe | null> = {
async GET(_, ctx) {
@ -13,13 +15,31 @@ export const handler: Handlers<Recipe | null> = {
};
export default function Greet(props: PageProps<Recipe>) {
const recipe = props.data;
const portion = recipe.meta?.portion;
const amount = useSignal(portion || 1);
return (
<MainLayout>
<RecipeHero recipe={props.data} />
<RecipeHero recipe={recipe} />
<div class="px-8 text-white mt-10">
<h3 class="text-3xl my-5">Ingredients</h3>
<IngredientsList ingredients={props.data.ingredients} />
<div class="flex items-center gap-8">
<h3 class="text-3xl my-5">Ingredients</h3>
{portion && <Counter count={amount} />}
</div>
<IngredientsList
ingredients={recipe.ingredients}
amount={amount}
portion={portion}
/>
<h3 class="text-3xl my-5">Preparation</h3>
<pre
class="whitespace-break-spaces"
dangerouslySetInnerHTML={{ __html: recipe.preparation || "" }}
>
{recipe.preparation}
</pre>
</div>
</MainLayout>
);