{#
  Text body, optionally with a links sidebar (textWithLinks block type).
#}
{% set textLayout = textLayout ?? 'editorial' %}
{% set richTextTemplate = textLayout == 'article' ? '_includes/articleRichText.twig' : '_includes/editorialRichText.twig' %}
{% set links = block.links ?? [] %}
{% set linkRows = [] %}
{% for link in links %}
    {% if link.linkUrl %}
        {% set linkRows = linkRows|merge([link]) %}
    {% endif %}
{% endfor %}
{% set hasLinks = linkRows|length > 0 %}

{% if block.text or hasLinks %}
<section class="py-s">
    {% if showTopRule %}
    <hr class="mt-xl mb-s border-0 border-t border-navy/25">
    {% endif %}

    {% if hasLinks %}
    <div class="mx-auto grid gap-xl pt-l lg:grid-cols-[minmax(0,1fr)_380px] lg:items-start">
        {% if block.text %}
        {% include richTextTemplate with { content: block.text } only %}
        {% endif %}

        <aside>
            <ul class="flex flex-col gap-s">
                {% for link in linkRows %}
                <li>
                    <a href="{{ link.linkUrl }}"
                        class="group flex items-center justify-between gap-s border-b pb-s font-rosario text--1 no-underline transition-colors duration-200 hover:text-turquoise">
                        <span>{{ link.linkText ?: link.linkUrl }}</span>
                        <svg class="h-4 w-4 shrink-0 transition-transform duration-200 group-hover:translate-x-1"
                            viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" aria-hidden="true">
                            <path d="M5 12h14M12 5l7 7-7 7" />
                        </svg>
                    </a>
                </li>
                {% endfor %}
            </ul>
        </aside>
    </div>
    {% else %}
    <div class="{{ textLayout == 'article' ? 'text-container' : 'container' }}">
        {% include richTextTemplate with { content: block.text, class: class ?? '' } only %}
    </div>
    {% endif %}
</section>
{% endif %}
