search.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {{/* Partial for built-in search and Algolia search. */}}
  2. {{ $search_provider := lower site.Params.features.search.provider }}
  3. {{ if in (slice "wowchemy" "algolia") $search_provider }}
  4. <aside class="search-modal" id="search">
  5. <div class="container">
  6. <section class="search-header">
  7. <div class="row no-gutters justify-content-between mb-3">
  8. <div class="col-6">
  9. <h1>{{ i18n "search" }}</h1>
  10. </div>
  11. <div class="col-6 col-search-close">
  12. <a class="js-search" href="#" aria-label="{{i18n "close" | default "Close"}}"><i class="fas fa-times-circle text-muted" aria-hidden="true"></i></a>
  13. </div>
  14. </div>
  15. <div id="search-box">
  16. {{ if eq $search_provider "wowchemy" }}
  17. <input name="q" id="search-query" placeholder="{{i18n "search_placeholder"}}" autocapitalize="off"
  18. autocomplete="off" autocorrect="off" spellcheck="false" type="search" class="form-control"
  19. aria-label="{{i18n "search_placeholder"}}">
  20. {{ else }}
  21. <!-- Search box will appear here -->
  22. {{ end }}
  23. </div>
  24. {{ $search_queries := false }}
  25. {{ if isset site.Data (printf "search_queries.%s" .Site.Language.Lang) }}
  26. {{ $search_queries = index site.Data (printf "search_queries.%s" .Site.Language.Lang) }}
  27. {{ else if isset site.Data "search_queries" }}
  28. {{ $search_queries = site.Data.search_queries }}
  29. {{end}}
  30. {{ if $search_queries }}
  31. <div id="search-common-queries" class="pt-3">
  32. <div class="font-weight-bold pb-3">{{ i18n "search_common_queries" | default "Common searches" }}</div>
  33. <ul class="fa-ul">
  34. {{ range $search_queries }}
  35. <li class="pb-3">
  36. <a href="{{.link | relURL}}"><i class="fa-li fas fa-search" aria-hidden="true"></i><span class="pl-1">{{.query | markdownify | emojify}}</span></a>
  37. </li>
  38. {{ end }}
  39. </ul>
  40. </div>
  41. {{ end }}
  42. </section>
  43. <section class="section-search-results">
  44. <div id="search-hits">
  45. <!-- Search results will appear here -->
  46. </div>
  47. </section>
  48. </div>
  49. </aside>
  50. {{end}}