{% extends "base.html" %}

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

{% block title %}
    {{ page.title }} - {{ config.title }}
{% endblock %}

{% block page_meta %}
    {% if page.description %}
        <meta name="description" content="{{ page.description | safe | default(value='') | truncate(length=150) }}" />
    {% endif %}
    {% if page.extra.author or config.extra.author %}
        <meta name="author" content="{% if page.extra.author %}{{ page.extra.author }}{% else %}{{ config.extra.author }}{% endif %}" />
    {% endif %}
{% endblock %}

{% block nav %}
    <span><a class="stealth" href="..">../{{ page.slug }}</a></span>
    <noscript id="theme-toggle-placeholder"></noscript>
{% endblock %}

{% block content %}
    <h1 id="page-title">{{ page.title }}</h1>
    {{ page.content | safe }}
{% endblock %}

{% block aside %}
    {% if page.date -%}
    <span id="page-publish-date">Published: <time>{{ page.date }}</time>{% if page.updated %}, Updated: <time>{{ page.updated }}</time>{% endif %}</span>
    {%- endif %}
    {% if page.extra.author %}
    <span id="page-author">By: {{ page.extra.author }}</span>
    {% endif %}
    <span id="page-read-time">Read time: <time>{{ page.reading_time }}</time> minutes</span>
    {% if page.extra.external_reading %}
    <span id="page-external-reading">
        External reading:
        <ul>
        {% for extlink in page.extra.external_reading %}
            <li><a href="{{ extlink.url }}">{{ extlink.text }}</a></li>    
        {% endfor %}
        </ul>
    </span>
    {% endif %}
    {% if config.extra.xscratch_debug_info %}
    <span><strong>Debug info:</strong></span>
    {{ macros::debug(thing=page, label="page", recurse=2) }}
    {% endif %}
{% endblock %}

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