{% extends "base.html" %}

{% import "macros.html" as macros %}

{% block content %}
    {% for page in section.pages | reverse %}
        <h1><a href="{{ page.permalink }}" class="stealth">{{ page.title }}</a></h1>
        {% if page.date %}
            <span>{{ page.date | date(format="%Y-%m-%d") }}</span>
        {% endif %}
        {% if page.summary %}
            {% if config.extra.summary_max_length %}
                {% set sum = page.summary | safe | truncate(length=config.extra.summary_max_length) %}
            {% else %}
                {% set sum = page.summary | safe %}
            {% endif %}
            <p>{{ sum | safe }}</p>
        {% endif %}
        {% if not loop.last %}<hr>{% endif %}
    {% endfor %}
{% endblock %}

{% block footer %}
<span>
    {{ now() | date(format='%Y') }}
    {% if section.extra.author %}
    {{ section.extra.author }}
    {% elif config.extra.author %}
    {{ config.extra.author }}
    {% endif %}
</span>
{% endblock %}

{% block aside %}
    {{ macros::parent_tree(ancestors=section.ancestors) }}

    {% if section.title %}
    <h1>{{ section.title }}</h1>
    {% endif %}
    {% if section.content %}
    {{ section.content | safe }}
    {% endif %}
    {% if section.subsections %}
        {{ config.extra.subsections_string | default(value="Subsections:") }}
        {{ macros::subsection_tree(subs=section.subsections) }}
    {% endif %}

    {% if config.extra.xscratch_debug_info %}
    <span><strong>Debug info:</strong></span>
    {{ macros::debug(thing=section, label="section", recurse=2) }}
    {% endif %}
{% endblock %}