{% extends 'simplewiki/base.html' %}
{% load i18n %}
{% load humanize %}
{% load static %}
{% load markdown_filters %}
{% load custom_filters %}

{% block details %}
<form method="GET" action="{% url 'simplewiki:search' %}">
    <div class="input-group mb-3">
      <input type="text" class="form-control" type="search" name="query" placeholder="Search.." id="searchInput">
        <button class="btn btn-success" type="submit">
            <i class="fas fa-search"></i>
            Go!
        </button>
    </div>
  </form>
    <br />
    {% for item in available_results %}
    <div class="card card-primary" style="margin-bottom: 1rem;">
        <div class="card-header">
            <div class="card-title">
                <i class="{{ item.icon }}"></i>
                <a href="{% url 'simplewiki:dynamic_menu' menu_path=item.menu.path %}" style="text-decoration: none;">
                    {{ item.title }}
                </a>
            </div>
        </div>
        <div class="card-body">
            <p>
                {{ item.content|markdown|safe }}
            </p>
        </div>
    </div>
    {% empty %}
        {% if oldQuery %}
            <div class="alert alert-warning" role="alert">
                Nothing found for "<b>{{ oldQuery }}</b>"
            </div>
        {% endif %}
    {% endfor %}
{% endblock %}

{% block extra_javascript %}
{% if oldQuery %}
    <script>
        document.getElementById("searchInput").value = '{{ oldQuery|escapejs }}';
    </script>
{% endif %}
{% endblock %}

{% block extra_script %}
{% endblock %}
