{% extends "puput/base.html" %}

{% load static i18n wagtailcore_tags wagtailimages_tags puput_tags %}

{% block title %}{% if search_term %}{{ search_term }} | {{ blog_page.title }}{% else %}{{ block.super }}{% endif %}{% endblock title %}
{% block meta_title %}{% if search_term %}{% trans 'Entries for' %} {{ search_type }} {{ search_term }}{% else %}{{ block.super }}{% endif %}{% endblock meta_title %}
{% block meta_description %}{% if search_term %}{% trans 'Entries for' %} {{ search_type }} {{ search_term }}{% else %}{{ block.super }}{% endif %}{% endblock meta_description %}


{% block content %}
    {% with per_page=blog_page.num_entries_page %}
        {# 'paginate' tag cannot render dotted variables, so we need to create a context var #}
        {% paginate per_page entries %}
        {% if search_term %}
            <div class="searchTerm">{% trans 'Entries for' %} {{ search_type }} "{{ search_term }}"</div>
        {% endif %}
        {% for entry in entries %}
            <article class="box page-content blog_grid">
                {% include 'puput/entry_page_header.html' %}
                <section>
                    <span class="img-responsive">
                        {% image entry.header_image fill-800x240 as header_image %}
                        <img alt="{{ entry.header_image.title }}" src="{{ header_image.url }}">
                    </span>
                </section>
                <section class="article">
                    {% if entry.excerpt %}
                        {{ entry.excerpt|richtext }}
                    {% else %}
                        {{ entry.body|richtext|truncatewords_html:70 }}
                    {% endif %}
                    <a class="blog_btn continue" href="{% entry_url entry blog_page %}">{% trans 'Continue reading' %} &raquo;</a>
                </section>
            </article>
        {% empty %}
            <span>{% trans 'No results founds.' %}</span>
        {% endfor %}
        <div class="pagination">
            {% show_paginator %}
        </div>
    {% endwith %}
{% endblock content %}
