{% extends 'partials/base.html.twig' %}

{% set collection = page.collection() %}
{% set blog = page.find(header_var('blog_url')|defined(theme_var('blog_page'))) %}
{% set show_breadcrumbs = header_var('show_breadcrumbs')|defined(true) %}
{% set show_pagination = header_var('show_pagination')|defined(true) %}

{# Set page title by taxonomy #}
{% if uri.param('category') %}
	{% set listing_title = 'FUTURE.BLOG.LISTING_TITLE_CATEGORY'|t ~ uri.param('category') %}
{% elseif uri.param('tag') %}
	{% set listing_title = 'FUTURE.BLOG.LISTING_TITLE_TAG'|t ~ uri.param('tag') %}
{% elseif uri.param('author') %}
	{% set listing_title = 'FUTURE.BLOG.LISTING_TITLE_AUTHOR'|t ~ uri.param('author') %}
{% elseif uri.param('archives_month') %}
    {% set listing_title = 'FUTURE.BLOG.LISTING_TITLE_MONTH'|t ~ uri.param('archives_month')|replace({'_': ' '}) %}
{% else %}
    {% set listing_title = page.header.subtitle|raw %}
{% endif %}

{% block menu %}
  {% include 'partials/sidebar_right.html.twig' %}
{% endblock %}

{% block content %}
<article class="heading">
    {% if image %}
    <span class="image featured">
      {{ image.cropZoom(1038,437).loading('lazy').attribute('decoding','async').html(title, title)|raw }}
    </span>
    {% endif %}
    <div class="title">
      <h1 itemprop="headline">{{ title }}</h1>
      {% if listing_title %}
        <p>{{ listing_title|raw }}</p>
      {% endif %}
    </div>
    
    {{ page.content|raw }}
    
    {% if show_breadcrumbs and config.plugins.breadcrumbs.enabled %}
      {% include 'partials/breadcrumbs.html.twig' %}
    {% endif %}
</article>
  {% for child in collection %}
    {% set datestamp = include('partials/page-bits/date.html.twig', { 'page': child }) %}
    {% include 'partials/blog_item.html.twig' with {blog: page, page:child, 'title': child.title|raw, 'subtitle': child.header.subtitle|raw, 'listing': true, 'truncate':true} %}
  {% endfor %}

  {% if show_pagination and config.plugins.pagination.enabled and collection.params.pagination %}
    {% include 'partials/pagination.html.twig' with {'base_url': page.url, 'pagination': collection.params.pagination} %}
  {% endif %}

  {% if show_sidebar == false %}
    <section id="footer" class="align-center">
      {% include 'partials/sidebar-bits/footer.html.twig' %}
    </section>
  {% endif %}
{% endblock %}

{% block sidebar %}
{% if show_sidebar == true %}
    {% include 'partials/sidebar_left.html.twig' %}
{% endif %}
{% endblock %}
