From ab068ee898a98a9b2d68abb3a2c71cede02d1e19 Mon Sep 17 00:00:00 2001 From: june Date: Wed, 13 Aug 2025 19:13:21 +1200 Subject: [PATCH] Add ingredients in the side of instructions. Quite messy... --- .../Detail/StepIngredientSideView.astro | 17 +++++++++++++++++ src/components/Detail/StepView.astro | 16 ++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/components/Detail/StepIngredientSideView.astro diff --git a/src/components/Detail/StepIngredientSideView.astro b/src/components/Detail/StepIngredientSideView.astro new file mode 100644 index 0000000..5b6c7dd --- /dev/null +++ b/src/components/Detail/StepIngredientSideView.astro @@ -0,0 +1,17 @@ +--- +import client from "@/data/pocketbase"; + +const { ingredients, class: className } = Astro.props; + +const ings = await Promise.all( + ingredients.map(async i => await client.collection("ingredients").getOne(i)) +) +--- + +
+ {ings.map(i => ( +
+

• {i.quantity} {i.unit || " "} {i.name}

+
+ ))} +
\ No newline at end of file diff --git a/src/components/Detail/StepView.astro b/src/components/Detail/StepView.astro index d725388..a7652b6 100644 --- a/src/components/Detail/StepView.astro +++ b/src/components/Detail/StepView.astro @@ -1,13 +1,25 @@ --- +import { record } from "astro:schema" +import client from "@/data/pocketbase" +import StepIngredientSideView from "./StepIngredientSideView.astro" + const { steps } = Astro.props ---

Steps

{ steps.map(s => ( -
+

Step {s.index + 1}

-

{s.instruction}

+ +
+

{s.instruction}

+ {s.ingredients && s.ingredients.length > 0 && ( +
+ +
+ )} +
)) }
\ No newline at end of file