{% sw_extends '@Storefront/storefront/component/product/breadcrumb.html.twig' %}
{% block component_product_breadcrumb_category %}
{% set productShowInBreadcrumbMode = dreiscSeoCustomSettings.richSnippets.breadcrumb.product.showInBreadcrumbMode %}
{% set homeShowInBreadcrumbMode = dreiscSeoCustomSettings.richSnippets.breadcrumb.home.showInBreadcrumbMode %}
{% set productShowInBreadcrumb = 'onlyShop' == productShowInBreadcrumbMode or 'shopAndJsonLd' == productShowInBreadcrumbMode %}
{% set homeShowInBreadcrumb = 'onlyShop' == homeShowInBreadcrumbMode or 'shopAndJsonLd' == homeShowInBreadcrumbMode %}
{# Make sure, that we are before the first item #}
{# EXPLAIN: key = current id of the breadcrumb array; breadcrumb|keys|first = id of the first breadcrumb item #}
{% block dreisc_seo__component_product_breadcrumb_category__add_home_breadcrumb %}
{% if homeShowInBreadcrumb and breadcrumb|keys|first == key %}
{% sw_include '@Storefront/storefront/dreisc-seo/component/home/breadcrumb.html.twig' with { } only %}
{% endif %}
{% endblock %}
{% if productShowInBreadcrumb %}
{% block dreisc_seo__component_product_breadcrumb_category__modify_default %}
{# We make sure that we do not set the is-active class because the product name is issued as a bread crumb. #}
<a href="{{ seoUrl('frontend.navigation.page', { navigationId: key }) }}">
{% block component_product_breadcrumb_link_name %}
{{ item }}
{% endblock %}
</a>
{% endblock %}
{% else %}
{# Otherwise: Call the parent as fallback #}
{{ parent() }}
{% endif %}
{# Check, if we reached the last breadcrumb item #}
{# EXPLAIN: key = current id of the breadcrumb array; product.categoryTree|last = last id of the breadcrumb array #}
{% block dreisc_seo__component_product_breadcrumb_category__add_product_breadcrumb %}
{% if productShowInBreadcrumb and product.categoryTree|last == key %}
{% sw_include '@Storefront/storefront/dreisc-seo/component/product/breadcrumb.html.twig' with {
product: product
} only %}
{% endif %}
{% endblock %}
{% endblock %}