diff --git a/src/components/Detail/InfoView.astro b/src/components/Detail/InfoView.astro new file mode 100644 index 0000000..2516136 --- /dev/null +++ b/src/components/Detail/InfoView.astro @@ -0,0 +1,29 @@ +--- +import TagRow from "../Card/TagRow.astro"; + + +const { re } = Astro.props + +function formatTime(seconds) { + if (seconds === 0) return null + const h = Math.floor(seconds / 3600); + const m = Math.floor((seconds % 3600) / 60); + let result = ""; + if (h > 0) result += `${h}h`; + if (m > 0) result += `${m}m`; + if (result === "") result = "0m"; + return result; +} + +const workTime = formatTime(re.worktime) +const waitTime = formatTime(re.waittime) +--- + +

{re.description}

+
+ {re.servings !== 0 && (

Serves: {re.servings}

)} + {workTime && (

{workTime} Work

)} + {waitTime && (

{waitTime} Wait

)} + {re.rating !== 0 && (

{re.rating}

/10

)} +
+ \ No newline at end of file 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 new file mode 100644 index 0000000..a7652b6 --- /dev/null +++ b/src/components/Detail/StepView.astro @@ -0,0 +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.ingredients && s.ingredients.length > 0 && ( +
+ +
+ )} +
+
+ )) } +
\ No newline at end of file diff --git a/src/pages/recipe/[recipeid].astro b/src/pages/recipe/[recipeid].astro index 7e3df49..052862f 100644 --- a/src/pages/recipe/[recipeid].astro +++ b/src/pages/recipe/[recipeid].astro @@ -3,6 +3,8 @@ import client from "@/data/pocketbase"; import SiteLayout from "@/layouts/base"; import ImageCarousel from "@/components/Detail/ImageCarousel"; import IngredientTableView from "@/components/Detail/IngredientTableView"; +import StepView from "@/components/Detail/StepView"; +import InfoView from "@/components/Detail/InfoView"; const { recipeid } = Astro.params; @@ -23,56 +25,26 @@ const ingredients = await Promise.all( await client.collection("ingredients").getOne(s) ) ) - -function formatTime(seconds) { - if (seconds === 0) return null - const h = Math.floor(seconds / 3600); - const m = Math.floor((seconds % 3600) / 60); - let result = ""; - if (h > 0) result += `${h}h`; - if (m > 0) result += `${m}m`; - if (result === "") result = "0m"; - return result; -} - -const workTime = formatTime(re.worktime) -const waitTime = formatTime(re.waittime) ---
-
+

{re.name}

-

{re.description}

-
- {re.servings !== 0 && (

Serves: {re.servings}

)} - {workTime && (

{workTime} work

)} - {waitTime && (

{waitTime} wait

)} - {re.rating !== 0 && (

{re.rating}⭐️

)} -
+

Ingredients

-
+
-
-

Steps

- { steps.map(s => ( -
-

Step {s.index + 1}

-

{s.instruction}

-
- )) } -
- - +