diff --git a/api/pb_migrations/1755056714_updated_recipes.js b/api/pb_migrations/1755056714_updated_recipes.js new file mode 100644 index 0000000..e829e0d --- /dev/null +++ b/api/pb_migrations/1755056714_updated_recipes.js @@ -0,0 +1,44 @@ +/// +migrate((app) => { + const collection = app.findCollectionByNameOrId("pbc_842702175") + + // add field + collection.fields.addAt(9, new Field({ + "hidden": false, + "id": "number1485952547", + "max": null, + "min": null, + "name": "worktime", + "onlyInt": true, + "presentable": false, + "required": false, + "system": false, + "type": "number" + })) + + // add field + collection.fields.addAt(10, new Field({ + "hidden": false, + "id": "number2198822773", + "max": null, + "min": null, + "name": "waittime", + "onlyInt": true, + "presentable": false, + "required": false, + "system": false, + "type": "number" + })) + + return app.save(collection) +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_842702175") + + // remove field + collection.fields.removeById("number1485952547") + + // remove field + collection.fields.removeById("number2198822773") + + return app.save(collection) +}) diff --git a/src/components/Detail/ImageCarousel.astro b/src/components/Detail/ImageCarousel.astro index 7df4b49..ece401e 100644 --- a/src/components/Detail/ImageCarousel.astro +++ b/src/components/Detail/ImageCarousel.astro @@ -50,9 +50,9 @@ const links = await Promise.all(
- + - +
\ No newline at end of file diff --git a/src/pages/recipe/[recipeid].astro b/src/pages/recipe/[recipeid].astro index 75662ef..7e3df49 100644 --- a/src/pages/recipe/[recipeid].astro +++ b/src/pages/recipe/[recipeid].astro @@ -23,6 +23,20 @@ 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) --- @@ -30,6 +44,16 @@ const ingredients = await Promise.all(

{re.name}

+ + +

{re.description}

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

Serves: {re.servings}

)} + {workTime && (

{workTime} work

)} + {waitTime && (

{waitTime} wait

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

{re.rating}⭐️

)} +
+

Ingredients

@@ -37,8 +61,9 @@ const ingredients = await Promise.all(
+
-

Steps

+

Steps

{ steps.map(s => (

Step {s.index + 1}