<aside aria-label="{{ __('Blog sidebar') }}">
    {% if sidebar.widgets_active %}
        {{ sidebar.widgets_html|raw }}
    {% else %}
        {% if sidebar.recent_posts is defined and sidebar.recent_posts|length > 0 %}
            <div class="mb-4">
                <h3 class="sidebar-heading h6 text-uppercase fw-semibold">
                    {{ __('Recent Posts') }}
                </h3>
                <ul class="list-unstyled">
                    {% for post in sidebar.recent_posts %}
                        <li class="mb-2">
                            <a href="{{ post.url }}" class="text-decoration-none">{{ post.title }}</a>
                            <br>
                            <small class="text-body-secondary">{{ post.date }}</small>
                        </li>
                    {% endfor %}
                </ul>
            </div>

            <hr>
        {% endif %}

        <div class="mb-4">
            <h3 class="sidebar-heading h6 text-uppercase fw-semibold">
                {{ __('Search') }}
            </h3>
            {% include 'partials/search-form.html.twig' %}
        </div>

        <hr>

        {% if sidebar.tags is defined and sidebar.tags|length > 0 %}
            <div class="mb-4">
                <h3 class="sidebar-heading h6 text-uppercase fw-semibold">
                    {{ __('Tags') }}
                </h3>
                <div>
                    {% for tag in sidebar.tags %}
                        <a href="{{ tag.url }}" class="badge bg-secondary text-decoration-none me-1 mb-1">
                            {{ tag.name }}
                        </a>
                    {% endfor %}
                </div>
            </div>
        {% endif %}
    {% endif %}
</aside>
