wiki-grav/plugins/tntsearch/templates/partials/tntsearch.html.twig

31 lines
1.9 KiB
Twig
Raw Normal View History

{% set url = url|default(base_url|rtrim('/') ~ '/' ~ config.get('plugins.tntsearch.query_route', 's')|trim('/')) %}
{% set limit = limit|default(config.get('plugins.tntsearch.limit', 20)) %}
{% set snippet = snippet|default(config.get('plugins.tntsearch.snippet', 300)) %}
{% set min = min|default(config.get('plugins.tntsearch.min', 3)) %}
{% set search_type = search_type|default(config.get('plugins.tntsearch.search_type', 'auto')) %}
{% set placeholder = placeholder|default('Search...') %}
{% set live_update = in_page ? live_update|default(config.get('plugins.tntsearch.live_uri_update', 1)) : 0 %}
{% set nojs_action = config.get('plugins.tntsearch.search_route', '/search')|trim('/') %}
{% set options = { uri: url, limit: limit, snippet: snippet, min: min, in_page: in_page, live_update: live_update, search_type: search_type } %}
<form role="form" class="tntsearch-form" action="{{ nojs_action }}" method="get">
{% block tntsearch_input %}
<div id="tntsearch-wrapper" class="form-group{{ dropdown ? ' tntsearch-dropdown' : '' }}">
<input type="text" name="q" class="form-control form-input tntsearch-field{{ in_page ? ' tntsearch-field-inpage' : '' }}" data-tntsearch="{{ options|json_encode|e('html_attr') }}" placeholder="{{ placeholder }}" value="{{ not dropdown ? query|e : '' }}" autofocus>
<span class="tntsearch-clear"{{ not query or dropdown ? ' style="display: none;"' : '' }}>&times;</span>
</div>
{% endblock %}
<div class="tntsearch-results{{ in_page ? ' tntsearch-results-inpage' : '' }}">
{% if tntsearch_results is defined and tntsearch_results is not empty and in_page %}
{% include 'tntquery-ajax.html.twig' %}
{% endif %}
</div>
{% if config.get('plugins.tntsearch.powered_by') %}
<p class="tntsearch-powered-by">
{{ "PLUGIN_TNTSEARCH.POWERED_BY"|t("<a href='https://github.com/trilbymedia/grav-plugin-tntsearch' target='_blank'>TNTSearch</a>")|raw }}
</p>
{% endif %}
</form>