{% macro content(page) %}

{% set separator = config.extra.separator | default(value="•") %}

<main>
    <article>
        <div class="article-title">
            {{ page.title }}
        </div>

        <ul class="meta">
            {% if page.draft %}
                <li class="draft-label">DRAFT</li>
            {% endif %}

            {% if page.date %}
                <li>{{ macros_format_date::format_date(date=page.date, short=true) }} {{ separator }}</li>
            {% endif %}

            <li title="{{ page.word_count }} words">&nbsp;{{ page.reading_time }} min read</li>

            {% if page.taxonomies and page.taxonomies.tags %}
                <li>&nbsp;{{ separator }}&nbsp;Tags:&nbsp;</li>
                {% for tag in page.taxonomies.tags %}
                    <li><a href={{ get_taxonomy_url(kind='tags' , name=tag) | safe }}>{{ tag }}</a>
                    {%- if not loop.last -%}
                        ,&nbsp;
                    {%- endif -%}
                    </li>
                {% endfor %}
            {% endif %}

            {% if page.updated %}
                </ul><ul class="meta last-updated"><li>Last updated on {{ macros_format_date::format_date(date=page.updated, short=true) }}</li>
            {% endif %}
        </ul>

        {% if page.extra.tldr %}
            <div class="tldr">
                <h3>TL;DR:</h3>
                <p>{{ page.extra.tldr }}</p>
            </div>
        {% endif %}

        {# Optional table of contents #}
        {% if page.extra.toc | default(value=false) %}
        {% if page.toc %}
            <div class="toc-container">
            <h3>Table of Contents</h3>
            <ul>
                {% for h1 in page.toc %}
                <li>
                    <a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
                    {% if h1.children %}
                    <ul>
                        {% for h2 in h1.children %}
                        <li>
                            <a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
                            {% if h2.children %}
                            <ul>
                                {% for h3 in h2.children %}
                                <li>
                                    <a href="{{ h3.permalink | safe }}">{{ h3.title }}</a>
                                </li>
                                {% endfor %}
                            </ul>
                            {% endif %}
                        </li>
                        {% endfor %}
                    </ul>
                    {% endif %}
                </li>
                {% endfor %}
            </ul>
            </div>
        {% endif %}
        {% endif %}

        <section class="body">
            {{ page.content | safe }}
        </section>

    </article>
</main>

{% endmacro content %}
