feat: url scraper to recipe
This commit is contained in:
35
lib/parseIngredient.ts
Normal file
35
lib/parseIngredient.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { parseIngredient as _parseIngredient } from "https://esm.sh/parse-ingredient@1.0.1";
|
||||
|
||||
export function parseIngredient(text: string) {
|
||||
const ing = _parseIngredient(text, {
|
||||
additionalUOMs: {
|
||||
tableSpoon: {
|
||||
short: "EL",
|
||||
plural: "Table Spoons",
|
||||
alternates: ["el", "EL", "Tbsp", "tbsp"],
|
||||
},
|
||||
teaSpoon: {
|
||||
short: "TL",
|
||||
plural: "Tea Spoon",
|
||||
alternates: ["tl", "TL", "Tsp", "tsp", "teaspoon"],
|
||||
},
|
||||
litre: {
|
||||
short: "L",
|
||||
plural: "liters",
|
||||
alternates: ["L", "l"],
|
||||
},
|
||||
paket: {
|
||||
short: "Paket",
|
||||
plural: "Pakets",
|
||||
alternates: ["Paket", "paket"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
name: ing[0].description,
|
||||
unit: ing[0].unitOfMeasure || "",
|
||||
quantity: ing[0].quantity?.toString() || "",
|
||||
note: "",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user