in lib/recipes-data/src/lib/extract-recipes.ts [56:81]
export function extractRecipeData(
content: Content,
block: Block,
sponsorship: Sponsorship[],
): Array<RecipeReferenceWithoutChecksum | null> {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- to fix error when elements are undefined , example if main block does not have any elements.
if (!block?.elements) {
return [];
} else {
const recipeDates: RecipeDates = {
lastModifiedDate: capiDateTimeToDate(block.lastModifiedDate),
firstPublishedDate: getFirstPublishedDate(block, content),
publishedDate: getPublishedDate(block, content),
};
return block.elements
.filter((elem) => elem.type === ElementType.RECIPE)
.map((recp) =>
parseJsonBlob(
content.id,
recp.recipeTypeData?.recipeJson as string,
sponsorship,
recipeDates,
),
);
}
}