diff --git a/src/components/Detail/InfoView.astro b/src/components/Detail/InfoView.astro new file mode 100644 index 0000000..1a0d36f --- /dev/null +++ b/src/components/Detail/InfoView.astro @@ -0,0 +1,26 @@ +--- + +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/StepView.astro b/src/components/Detail/StepView.astro new file mode 100644 index 0000000..d725388 --- /dev/null +++ b/src/components/Detail/StepView.astro @@ -0,0 +1,13 @@ +--- +const { steps } = Astro.props +--- + +
+

Steps

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

Step {s.index + 1}

+

{s.instruction}

+
+ )) } +
\ No newline at end of file diff --git a/src/pages/recipe/[recipeid].astro b/src/pages/recipe/[recipeid].astro index 1dedf6d..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,20 +25,6 @@ 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) --- @@ -46,13 +34,7 @@ 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}

/10

)} -
+

Ingredients

@@ -62,17 +44,7 @@ const waitTime = formatTime(re.waittime) -
-

Steps

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

Step {s.index + 1}

-

{s.instruction}

-
- )) } -
- - +