{% macro list_title(pages, tag_name=false) %}
    {% if tag_name %}
        <h1>Entries tagged - "{{ term.name }}"</h1>
    {% else %}
        <h1 class="page-title">All articles</h1>
    {% endif %}

    <ul class="posts">
        {% for page in pages %}
            <li class="post">
                <a href="{{ page.permalink }}">{{ page.title }}</a>
                <span class="meta">{{ page.date | date(format="%Y-%m-%d") }}</span>
            </li>
        {% endfor %}
    </ul>
{% endmacro list_title %}

{% macro list_posts(pages, extra) %}
    <ul>
    {%- for page in pages %}
        {%- if page.draft %}
            {% continue %}
        {% endif -%}

        <section class="list-item">
            <h1 class="title">
                <a href={{ page.permalink }}>{{page.title}}</a>
            </h1>

            <time>{{ page.date | date(format="%Y-%m-%d") }}</time>
            <span>| {{ page.reading_time }} {{ config.extra.translations[lang][0].read_time }}</span>
            {% if page.extra.author %}
                <span>| {{extra.translations[lang][0].posted_by }} <a href="{{ page.extra.author.social }}" target="_blank">{{ page.extra.author.name }}</a></span>
            {% endif %}

            <br />
            <div class="description">
                {% if page.description %}
                    {{ page.description }}
                {% elif page.summary %}
                    {{ page.summary }}&hellip;
                {% else %}
                    {% set hide_read_more = true %}
                {% endif %}
            </div>

            {% if not hide_read_more %}
                <a class="readmore" href={{ page.permalink }}>{{ extra.translations[lang][0].show_more }}</a>
            {% endif %}
        </section>

    {% endfor -%}
    </ul>
{% endmacro list_posts %}


{% macro tags(page, short=false) %}
    {%- if page.taxonomies and page.taxonomies.tags %}
        <span class="post-tags-inline">
            {%- if short %}
                ::
                {%- set sep = "," -%}
            {% else %}
                :: tags:&nbsp;
                {%- set sep = "&nbsp;" -%}
            {% endif -%}
            {%- for tag in page.taxonomies.tags %}
                <a class="post-tag" href="{{ get_taxonomy_url(kind='tags', name=tag) | safe }}">#{{ tag }}</a>
                {%- if not loop.last %}{{ sep | safe }}{% endif -%}
            {% endfor -%}
        </span>
    {% endif -%}
{% endmacro tags %}

{% macro content(page, extra) %}
<main>
    <article>
        <div class="title">
            <h1 class="title">{{ page.title }}</h1>
            <div class="meta">
                {% if page.extra.author %}
                    {{extra.translations[lang][0].posted_by }} <a href="{{ page.extra.author.social }}" target="_blank">{{ page.extra.author.name }}</a>
                {% endif %}
                {{ extra.translations[lang][0].posted_on }} {{ page.date | date(format="%Y-%m-%d") }}

                {% if page.draft %}
                    <span class="draft-label">DRAFT</span>
                {% endif %}
            </div>
        </div>

        {% if page.extra.tldr %}
            <div class="tldr">
                <strong>tl;dr:</strong>
                {{ page.extra.tldr }}
            </div>
        {% endif %}

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

        {% if page.taxonomies and page.taxonomies.tags %}
            <div class="post-tags">
                <nav class="nav tags">
                    <ul class="tags">
                        {% for tag in page.taxonomies.tags %}
                            <li><a href={{ get_taxonomy_url(kind='tags', name=tag) | safe }}>{{ tag }}</a></li>
                        {% endfor %}
                    </ul>
                </nav>
            </div>
        {% endif %}

    </article>
</main>
{% endmacro content %}
