{% extends 'layout.twig' %}
{% block title %}Search — {{ brand.name }}{% endblock %}
{% block content %}
    <section class="page-head">
        <div class="container">
            <h1>Search results</h1>
            <form action="{{ app_url('/kb/search') }}" method="get" class="kb-search">
                <input type="search" name="q" value="{{ q }}" placeholder="Search articles…" autofocus>
                <button type="submit">Search</button>
            </form>
        </div>
    </section>
    <section class="container">
        {% if q == '' %}
            <p class="muted">Enter a search term above.</p>
        {% elseif results is empty %}
            <p>No results for "<strong>{{ q }}</strong>". Try different keywords or <a href="{{ app_url('/tickets/new') }}">submit a ticket</a>.</p>
        {% else %}
            <p class="muted">Found {{ results|length }} match{{ results|length == 1 ? '' : 'es' }} for "<strong>{{ q }}</strong>"</p>
            <ul class="article-list">
                {% for r in results %}
                    <li>
                        <a href="{{ app_url('/kb/article/' ~ r.slug) }}"><strong>{{ r.title }}</strong></a>
                        {% if r.snippet %}
                            <p class="muted">{{ r.snippet|raw }}</p>
                        {% elseif r.excerpt %}
                            <p class="muted">{{ r.excerpt }}</p>
                        {% endif %}
                    </li>
                {% endfor %}
            </ul>
        {% endif %}
    </section>
{% endblock %}
