{% if recipes|length %}
{# count the number of recipes and show in recipe-result.twig for schema.org "position" #}
{% set recipeListNumber = 0 %}
{% set featuredCollectionIndex = 0 %}
{% for post in recipes %}
{% set recipeListNumber = recipeListNumber + 1 %}
{# Add 2 featured collection tile within recipes clusters #}
{% if collections|length %}
{% if (loop.index == 8 or loop.index == 12) and collections[featuredCollectionIndex] %}
{% if featuredCollectionIndex <= 2 %}
{% include "@views/components/tiles/featured-collection/template.twig" with {
classes: "grid-recipes-filtered__item grid-recipes-filtered__featured-collection",
label: "Featured Collection",
eyebrow: "27 Recipes",
heading: collections[featuredCollectionIndex].name,
href: collections[featuredCollectionIndex].link,
image: {
alt: "",
src: collections[featuredCollectionIndex].src,
srcTablet: collections[featuredCollectionIndex].srcTablet,
srcMobile: collections[featuredCollectionIndex].srcMobile
},
isSmall: true,
} %}
{% set featuredCollectionIndex = featuredCollectionIndex + 1 %}
{% endif %}
{% endif %}
{% endif %}
-
{# Set post thumbnail depending on whether we use a legacy image, or our new 1600x640 standard #}
{% if post.recipeFields.recipeCustomImage.sourceUrl %}
{% set postThumb = post.recipeFields.recipeCustomImage.sourceUrl %}
{% elseif post.featuredImage.node.sourceUrl %}
{% set postThumb = post.featuredImage.node.sourceUrl %}
{% else %}
{% set postThumb = post.featuredImage.node.mediaItemUrl ~ "?width=400&quality=75" %}
{% endif %}
{# Recipe save flow params #}
{% set postParams = {
name: post.slug,
createCollection: {
image: post.featuredImage.node.sourceUrl
}
} %}
{% set ingredientParams = post.childRecipe.node.ingredients %}
{% set recipeParams = {
type: 'recipe',
recipeId: post.childRecipe.node.childRecipeId,
name: post.title,
image: post.featuredImage.node.sourceUrl,
imageLarge: postParams.createCollection.image,
servings: post.childRecipe.node.servings,
servingsUnit: 'people',
parent_id: post.recipeId,
parent_url: post.link
} %}
{% set bookmarkParams = 'data-shelf-trigger=recipe-save-flow data-recipe-save-flow-id=' ~ recipeParams.recipeId ~ ' data-post=' ~ postParams|json_encode()|url_encode ~ ' data-recipe=' ~ recipeParams|json_encode()|url_encode ~ ' data-ingredients=' ~ ingredientParams|json_encode()|url_encode %}
{% include "@views/components/cards/recipe/template.twig" with {
classes: "",
eyebrow: post.childRecipe.node.prepTime ~ " Mins Prep - " ~ post.childRecipe.node.cookTime ~ " Mins Cook",
heading: post.title,
recommended: post.bvRating|number_format(1),
src: postThumb,
srcTablet: postThumb,
srcMobile: postThumb,
alt: post.thumbnail.alt,
href: post.link,
bookmarkParams: bookmarkParams,
tags: post.displayTags
} %}
{% endfor %}
{% else %}
No matches :(
{% endif %}