nutrition: detect recipe refs in ingredients, show in edit UI with multiplier
CI / update (push) Successful in 5m35s
CI / update (push) Successful in 5m35s
Skip embedding matching for anchor-tag ingredients that reference other recipes. Instead, mark them with recipeRef/recipeRefMultiplier fields so their nutrition is resolved via resolveReferencedNutrition with a user-configurable fraction. The edit UI shows these as teal REF badges with an editable "Anteil" input.
This commit is contained in:
@@ -157,7 +157,7 @@ export const GET: RequestHandler = async ({ params }) => {
|
||||
}
|
||||
|
||||
// Resolve nutrition from referenced recipes (base refs + anchor tags)
|
||||
recipe.referencedNutrition = await resolveReferencedNutrition(rawRecipe.ingredients || []);
|
||||
recipe.referencedNutrition = await resolveReferencedNutrition(rawRecipe.ingredients || [], rawRecipe.nutritionMappings);
|
||||
|
||||
// Merge English alt/caption with original image paths
|
||||
const imagesArray = Array.isArray(rawRecipe.images) ? rawRecipe.images : (rawRecipe.images ? [rawRecipe.images] : []);
|
||||
@@ -184,6 +184,6 @@ export const GET: RequestHandler = async ({ params }) => {
|
||||
recipe.instructions = mapBaseRecipeRefs(recipe.instructions);
|
||||
}
|
||||
// Resolve nutrition from referenced recipes (base refs + anchor tags)
|
||||
recipe.referencedNutrition = await resolveReferencedNutrition(rawRecipe.ingredients || []);
|
||||
recipe.referencedNutrition = await resolveReferencedNutrition(rawRecipe.ingredients || [], rawRecipe.nutritionMappings);
|
||||
return json(recipe);
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ export const GET: RequestHandler = async ({ params, setHeaders }) => {
|
||||
throw error(404, "Recipe not found");
|
||||
}
|
||||
|
||||
const referencedNutrition = await resolveReferencedNutrition(recipe.ingredients || []);
|
||||
const referencedNutrition = await resolveReferencedNutrition(recipe.ingredients || [], recipe.nutritionMappings);
|
||||
const jsonLd = generateRecipeJsonLd(recipe, referencedNutrition);
|
||||
|
||||
// Set appropriate headers for JSON-LD
|
||||
|
||||
Reference in New Issue
Block a user