From a6112cdc6b6140b7c25b5473c671be1262221ece Mon Sep 17 00:00:00 2001 From: June Date: Mon, 17 Nov 2025 14:51:03 +1300 Subject: [PATCH] Mostly adapt the infoview stuff --- web/src/components/detail/InfoView.astro | 29 ++++++++++++++++++++++++ web/src/pages/recipe/[id].astro | 16 ++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 web/src/components/detail/InfoView.astro diff --git a/web/src/components/detail/InfoView.astro b/web/src/components/detail/InfoView.astro new file mode 100644 index 0000000..0ef9e3e --- /dev/null +++ b/web/src/components/detail/InfoView.astro @@ -0,0 +1,29 @@ +--- +import TagRow from "@component/tagRow"; + + +const { cookTime, prepTime, description, servings, rating, tags } = Astro.props + +function formatTimeMin(minutes: number) { + if (minutes === 0) return null + const h = Math.floor(minutes / 60); + const m = minutes % 60; + let result = ""; + if (h > 0) result += `${h}h`; + if (m > 0) result += `${m}m`; + if (result === "") result = "0m"; + return result; +} + +// const workTime = formatTimeMin(re.worktime) +// const waitTime = formatTimeMin(re.waittime) +--- + +

{description}

+
+ {servings !== 0 && (

Serves: {servings}

)} + {prepTime && (

{prepTime} Prep

)} + {cookTime && (

{cookTime} Cook

)} + +
+ \ No newline at end of file diff --git a/web/src/pages/recipe/[id].astro b/web/src/pages/recipe/[id].astro index 739a04b..fadcc70 100644 --- a/web/src/pages/recipe/[id].astro +++ b/web/src/pages/recipe/[id].astro @@ -1,12 +1,16 @@ --- import Base from "@layout/Base"; import ImageCarousel from "@component/detail/ImageCarousel"; +import InfoView from "@component/detail/InfoView"; +import { Recipe } from "@tmlmt/cooklang-parser"; import { authPB } from "@data/pb"; const { id } = Astro.params - const pb = await authPB() + const re = await pb.collection('recipes').getOne(id as string) +const recipe = new Recipe(re.cooklang) + const images = await Promise.all( re.images.map(r => pb.files.getURL(re, r)) ) @@ -16,10 +20,16 @@ const images = await Promise.all(
-

{re.name}

+

{recipe.metadata.title ?? "Untitled Recipe"}

- +

Ingredients