{% extends "blog/base.html" %}
{% load blog_tags %}
{% block title %}Szukaj{% endblock %}

{% block content %}
  {% if query %}
    <h1>Posty zawierające "{{ query }}"</h1>
    <h3>
      {% with results.count as total_results %}
        Znaleziono {{ total_results }} wyników
      {% endwith %}
    </h3>
    {% for post in results %}
      <h4>
        <a href="{{ post.get_absolute_url }}">
          {{ post.title }}
        </a>
      </h4>
      {{ post.body|markdown|truncatewords_html:12 }}
    {% empty %}
      <p>Brak wyników dla podanego zapytania.</p>
    {% endfor %}
    <p><a href="{% url "blog:post_search" %}">Szukaj ponownie</a></p>
  {% else %}
    <h1>Szukaj postów</h1>
    <form method="get">
      {{ form.as_p }}
      <input type="submit" value="Szukaj">
    </form>
  {% endif %}
{% endblock %}
