<!doctype html>
<html lang="{{ language }}"{% if html_theme_attribute %} {{ html_theme_attribute }}{% endif %}>
  {% render 'partials/head', page_title: page_title, pico_stylesheet_href: pico_stylesheet_href %}
  <body>
    <main>
      {% if archive_context %}
        {% if show_archive_range_heading and min_date and max_date %}
          {% if archive_context.kind == 'tag' or archive_context.kind == 'category' %}
            <h1 class="archive-heading">{{ archive_context.name }} - {{ min_date.day }}.{{ min_date.month }}.{{ min_date.year }} - {{ max_date.day }}.{{ max_date.month }}.{{ max_date.year }}</h1>
          {% else %}
            <h1 class="archive-heading">{{ 'render.archive' | i18n: language }} {{ min_date.day }}.{{ min_date.month }}.{{ min_date.year }} - {{ max_date.day }}.{{ max_date.month }}.{{ max_date.year }}</h1>
          {% endif %}
        {% else %}
          {% if archive_context.kind == 'tag' or archive_context.kind == 'category' %}
            <h1 class="archive-heading">{{ archive_context.name }}</h1>
          {% elsif archive_context.kind == 'month' and archive_context.month and archive_context.year %}
            {% assign month_key = 'render.month.' | append: archive_context.month %}
            <h1 class="archive-heading">{{ 'render.archive' | i18n: language }} {{ month_key | i18n: language }} {{ archive_context.year }}</h1>
          {% elsif archive_context.kind == 'year' and archive_context.year %}
            <h1 class="archive-heading">{{ 'render.archive' | i18n: language }} {{ archive_context.year }}</h1>
          {% elsif archive_context.kind == 'day' and archive_context.day and archive_context.month and archive_context.year %}
            {% assign day_month_key = 'render.month.' | append: archive_context.month %}
            <h1 class="archive-heading">{{ 'render.archive' | i18n: language }} {{ archive_context.day }}. {{ day_month_key | i18n: language }} {{ archive_context.year }}</h1>
          {% else %}
            <h1 class="archive-heading">{{ page_title }}</h1>
          {% endif %}
        {% endif %}
      {% endif %}

      {% render 'partials/menu', menu_items: menu_items, language: language, calendar_initial_year: calendar_initial_year, calendar_initial_month: calendar_initial_month %}

      <section class="post-list" data-template="post-list" data-list-page="{{ is_list_page }}" data-first-page="{{ is_first_page }}" data-last-page="{{ is_last_page }}">
        {% for day_block in day_blocks %}
          {% if day_block.show_date_marker %}
            <section class="archive-day-group">
              <aside class="archive-day-marker"><span>{{ day_block.date_label }}</span></aside>
              <div class="archive-day-posts">
                {% for post in day_block.posts %}
                  <div class="post">
                    {% if post.show_title %}
                      {% assign canonical_post_href = canonical_post_path_by_slug[post.slug] %}
                      {% if canonical_post_href == blank %}
                        {% assign canonical_post_href = '/posts/' | append: post.slug %}
                      {% endif %}
                      <h2 class="post-title"><a href="{{ canonical_post_href }}">{{ post.title }}</a></h2>
                    {% endif %}
                    {{ post.content | markdown: post.id, post_data_json_by_id, canonical_post_path_by_slug, canonical_media_path_by_source_path, language }}
                  </div>
                {% endfor %}
              </div>
            </section>
          {% else %}
            {% for post in day_block.posts %}
              <div class="post">
                {% if post.show_title %}
                  {% assign canonical_post_href = canonical_post_path_by_slug[post.slug] %}
                  {% if canonical_post_href == blank %}
                    {% assign canonical_post_href = '/posts/' | append: post.slug %}
                  {% endif %}
                  <h2 class="post-title"><a href="{{ canonical_post_href }}">{{ post.title }}</a></h2>
                {% endif %}
                {{ post.content | markdown: post.id, post_data_json_by_id, canonical_post_path_by_slug, canonical_media_path_by_source_path, language }}
              </div>
            {% endfor %}
          {% endif %}

          {% if day_block.show_separator %}
            <div class="archive-day-separator" aria-hidden="true"></div>
          {% endif %}
        {% endfor %}
      </section>

      {% if has_prev_page or has_next_page %}
        <nav class="preview-pagination" aria-label="{{ 'render.pagination.label' | i18n: language }}">
          {% if has_prev_page %}
            <a href="{{ prev_page_href }}" class="preview-pagination-link" aria-label="{{ 'render.pagination.newer' | i18n: language }}">{{ 'render.pagination.newer' | i18n: language }}</a>
          {% else %}
            <span class="spacer"></span>
          {% endif %}

          {% if has_next_page %}
            <a href="{{ next_page_href }}" class="preview-pagination-link" aria-label="{{ 'render.pagination.older' | i18n: language }}">{{ 'render.pagination.older' | i18n: language }}</a>
          {% else %}
            <span class="spacer"></span>
          {% endif %}
        </nav>
      {% endif %}
    </main>
  </body>
</html>