{% extends "base.html" %}

{% block content %}
  {{ page.content }}
  {% set blog_posts = [] %}
  {% for page in nav.pages %}
    {% if page.url.startswith(config.extra.blog.dir) and page.meta.date is defined %}
      <!-- or "" suppresses "None" output-->
      {{ blog_posts.append( page ) or "" }}
    {% endif %}
  {% endfor %}

  {% for page in (blog_posts|sort(attribute="meta.date", reverse=True))[:config.extra.blog.list_length] %}
      <h2><a href="{{ page.url|url }}">{{ page.title }}</a></h2>
      <hr>
      {% include "partials/blog_metadata.html" %}
      <p>
        {{ page.meta.description }}
      </p>
      <!-- Use a hidden p tag to provide a preview -->
      {% if config.extra.blog.extended_preview %}
        <a href="{{ page.url|url }}#more">
          <span class="twemoji">
            {% include ".icons/octicons/arrow-right-24.svg" %}
          </span>
          Continue reading
          <hr>
        </a>
      {% endif %}
  {% endfor %}
{% endblock %}
