{% extends "cofcms/base_aside.html" %}
{% load wagtailcore_tags wagtailimages_tags cofcms_tags static i18n %}

{% block extra_head %}
    {{ block.super }}
    <script src="{% static "vendor/jquery/jquery-3.3.1.min.js" %}"></script>
    <script src="{% static "cofcms/js/script.js" %}"></script>
{% endblock %}
{% block aside_title %}{% trans "Accès rapide" %}{% endblock %}
{% block aside %}
    <ul class="directory">
        {% for entry in page.entries %}
            <li><a href="#{{ entry.slug }}">{{ entry.title }}</a></li>
        {% endfor %}
    </ul>
{% endblock %}

{% block content %}
    <section class="intro">
        <h1>{{ page.title }}</h1>
        <div>{{ page.introduction|richtext }}</div>
    </section>

    <section class="directory">
        {% for entry in page.entries %}
            <article class="entry" id="{{ entry.slug }}">
                {% if entry.image %}
                    <div class="entry-image">{% image entry.image width-150 class="entry-img" %}</div>
                {% endif %}
                <h2>{{ entry.title }}</h2>
                <div class="desc">{{ entry.body|richtext }}</div>
                {% if entry.links %}
                    <ul class="links">
                        {% for block in entry.links %}
                            <li>
                                {% if block.block_type == "lien" %}
                                    <a href="{{ block.value.url }}">{{ block.value.texte }}</a>
                                {% elif block.block_type == "contact" %}
                                    <span class="label">{{ block.value.texte }} :</span> <button data-mref="{{ block.value.email|obfuscate_mail }}" class="facteur">{% trans "Afficher l'adresse mail" %}</button>
                                {% else %}
                                    {% if block.value.nom %}<span class="label">{{ block.value.nom }} :</span> {% endif %}{{ block.value.texte }}
                                {% endif %}
                            </li>
                        {% endfor %}
                    </ul>
                {% endif %}
            </article>
        {% endfor %}
    </section>
{% endblock %}
