diff --git a/islands/IngredientsList.tsx b/islands/IngredientsList.tsx index 7488468..8b96ef9 100644 --- a/islands/IngredientsList.tsx +++ b/islands/IngredientsList.tsx @@ -6,9 +6,9 @@ import type { } from "../lib/recipes.ts"; import { FunctionalComponent } from "preact"; -type IngredientsProps = { - ingredients: Ingredients; -}; +function numberToString(num: number) { + return (Math.floor(num * 4) / 4).toString(); +} const Ingredient = ( { ingredient, amount, key = "", portion = 1 }: { @@ -27,7 +27,8 @@ const Ingredient = ( return ( - {finalAmount + (typeof unit === "string" ? unit : "")} + {numberToString(finalAmount || 0) + + (typeof unit === "string" ? unit : "")} {type} diff --git a/lib/resource/recipes.ts b/lib/resource/recipes.ts index 160b25a..341a4de 100644 --- a/lib/resource/recipes.ts +++ b/lib/resource/recipes.ts @@ -32,6 +32,7 @@ export type Recipe = { preparation?: string; tags: string[]; meta?: { + time?: string; link?: string; image?: string; rating?: number; @@ -57,7 +58,7 @@ function parseIngredientItem(listItem: DocumentChild): Ingredient | undefined { teaSpoon: { short: "TL", plural: "Tea Spoon", - alternates: ["tl", "TL", "Tsp", "tsp"], + alternates: ["tl", "TL", "Tsp", "tsp", "teaspoon"], }, litre: { short: "L", diff --git a/routes/movies/index.tsx b/routes/movies/index.tsx index 3c1280e..12e4dc0 100644 --- a/routes/movies/index.tsx +++ b/routes/movies/index.tsx @@ -15,7 +15,7 @@ export const handler: Handlers = { export default function Greet(props: PageProps) { return ( - +
) { const portion = recipe.meta?.portion; const amount = useSignal(portion || 1); + const subline = [ + recipe?.meta?.time && `Duration ${recipe.meta.time}`, + ].filter(Boolean); + return ( ${recipe.name}`}> - +

Ingredients