{% extends 'cjkcms/blocks/base_block.html' %}
{% load wagtailcore_tags wagtailimages_tags %}

{% block block_render %}

<div class="list-group
    {% if self.settings.custom_css_class %}
        {{self.settings.custom_css_class}}
    {% endif %}
    ">
    {% if self.title %}
    <h5 class="fw-bold">{{self.title}}</h5>
    {% endif %}
    {% for page in pages %}
    {% with page=page.specific %}
    <a class="list-group-item list-group-item-action flex-column align-items-start {% if request.path == page.url %}active{% endif %}" href="{{page.url}}">
    {% if self.show_preview %}
        <h5 class="mb-1">{{page.title}}</h5>
        <p class="mb-1">{{page.body_preview}}</p>
    {% else %}
        {{page.title}}
    {% endif %}
    </a>
    {% endwith %}
    {% endfor %}
    <div class="d-flex justify-content-center">
        {% if self.show_navigation %}
        {% if previous_page %}
        <a class="btn btn-outline-primary btn-sm me-2 mt-2 mb-2 flex-fill" href="{{previous_page.url}}">Previous</a>
        {% endif %}
        {% if next_page %}
        <a class="btn btn-primary btn-sm ms-2 mt-2 mb-2 flex-fill" href="{{next_page.url}}">Next</a>
        {% endif %}
        {% endif %}
</div>

{% endblock %}
