Skip to content

Commit

Permalink
Include 'usage info' when importing chefkoch recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
de-ich committed Jul 6, 2024
1 parent cc6a49c commit ff60378
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions functions/src/chefkoch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const internalFetchRecipe = async (recipeId: string, chefkochCookie?: string) =>

const convertToPartialRecipe = (chefkochRecipe: any): RecipeDraft => {
const recipe: any = {};

if (!chefkochRecipe.title) {
throw new Error('Unable to parse recipe name from chefkoch recipe!');
}
Expand All @@ -46,14 +46,14 @@ const convertToPartialRecipe = (chefkochRecipe: any): RecipeDraft => {
recipe.cookTime = chefkochRecipe.cookingTime;
recipe.totalTime = chefkochRecipe.totalTime;
recipe.recipeYield = chefkochRecipe.servings;

const ingredients: Ingredient[] = []

for (const ingredientGroup of chefkochRecipe.ingredientGroups || []) {
for (const chefkochIngredient of ingredientGroup.ingredients) {
let ingredientString;
try {
ingredientString = [chefkochIngredient.amount || '', chefkochIngredient.unit || '', chefkochIngredient.name].join(' ');
ingredientString = [chefkochIngredient.amount || '', chefkochIngredient.unit || '', chefkochIngredient.name].join(' ') + (chefkochIngredient.usageInfo || '');
const ingredient = parseIngredient(ingredientString);
ingredients.push(...ingredient);
} catch (err) {
Expand Down

0 comments on commit ff60378

Please sign in to comment.