{% raw %}
{% extends "base.html" %}

{% load static core_tags %}
{% load wagtailcore_tags wagtailimages_tags %}

{% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %}

{% block content %}
    <div class="articles nav {{self.get_effective_extra_style_hints}}">
      <h2 class="list-header">
        {% if self.image %}
          <a href="{% pageurl self %}">{% image self.image width-60 %}</a>
        {% endif %}
        {{self.title}}
      </h2>
      {% load_child_sections_for_section self as sections %}
      {% for section in sections %}
        <h2 class="list-header">
          {% if section.image %}
            <a href="{% pageurl section %}">{% image section.image width-60 %}</a>
          {% endif %}
          <a href="{% pageurl section %}">{{section.title}}</a>
          <ul class="list-block">
            <li>
              {% if section.description %}<p>{{section.description}}</p>{% endif %}
              {% load_descendant_articles_for_section section featured_in_section=True as featured_articles %}
              {% if featured_articles %}
              {% for article in featured_articles %}
                <h3><a href="{% pageurl article %}">{{article.title}}</a></h3>
                <p>{{article.subtitle}}</p>
              {% endfor %}
              {% endif %}
            </li>
          </ul>
        </h2>
      {% endfor %}

      {% load_child_articles_for_section self as articles %}
      {% for article in articles %}
      <ul class="list-block">
        <li>
          {% if article.image %}
          <a href="{% pageurl article %}">{% image article.image width-60 %}</a>
          {% endif %}
          <h3><a href="{% pageurl article %}">{{article.title}}</a></h3>
          <p>{{article.subtitle}}</p>
        </li>
      </ul>
      {% endfor %}

      {% if articles %}
      <div class="step-links l-indent l-indent--tall">
        {% if articles_paginated.has_previous %}
            <a href="?p={{ articles_paginated.previous_page_number }}">&larr;</a>
        {% endif %}
        <span class="current">
            Page {{ articles_paginated.number }} of {{ articles_paginated.paginator.num_pages }}
        </span>
        {% if articles_paginated.has_next %}
            <a href="?p={{ articles_paginated.next_page_number }}">&rarr;</a>
        {% endif %}
      </div>
      {% endif %}
      
    </div>
{% endblock %}
{% endraw %}
