search.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {{ define "main" }}
  2. <div class="wrap content">
  3. <article class="post_content">
  4. <section id="search-form-wrapper" class="p-3 p-lg-5 d-flex flex-column">
  5. <div class="my-auto">
  6. <!-- <h1>{{ .Title }}</h1> -->
  7. <a href="/search/"><img src="/images/aicurious_search.png" style="width: 20rem"></a>
  8. <p style="text-align: center;">Search for posts and notes<br>
  9. <a href="/categories/">&gt; Browse by Categories.</a><br>
  10. <a href="/tags/">&gt; Browse by Tags.</a></p>
  11. <form id="search-form" action="{{ "search" | absURL }}">
  12. <input id="search-query" placeholder="Type here to search" name="s" />
  13. <button id="search-btn" type="submit">Search</button>
  14. </form>
  15. <img id="loading-icon" src="/images/loading.svg" alt="loading" style="width: 4rem; height: 4rem;float: left; display: none;">
  16. <div id="search-results">
  17. </div>
  18. <div style="display: none;">Search database version: <span id="search-db-version">{{ now.Unix }}</span></div>
  19. </div>
  20. </section>
  21. <!-- this template is sucked in by search.js and appended to the search-results div above. So editing here will adjust style -->
  22. <script id="search-result-template" type="text/x-js-template">
  23. <div id="summary-${key}">
  24. <h4><a href="${link}">${title}</a></h4>
  25. <p>${snippet}</p>
  26. <!-- <p>${score}</p> -->
  27. <p>
  28. ${ isset tags }<b>Tags:</b> ${tags}, ${ end }
  29. ${ isset categories }<b>Categories:</b> ${categories}${ end }
  30. </p>
  31. </div>
  32. </script>
  33. <style>
  34. #search-form {
  35. font-size: 1rem;
  36. display: flex;
  37. width: 30rem;
  38. max-width: 100%;
  39. margin-left: auto;
  40. margin-right: auto;
  41. }
  42. #search-form input {
  43. width: auto;
  44. flex-grow: 2;
  45. margin: 0.2rem;
  46. }
  47. #search-form button {
  48. max-width: 5rem;
  49. flex-grow: 1;
  50. margin: 0.2rem;
  51. }
  52. .add-margin-top-search-form {
  53. margin-top: 10%;
  54. }
  55. </style>
  56. <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
  57. <script src="https://cdn.jsdelivr.net/npm/mark.js@8.11.1/dist/jquery.mark.min.js" integrity="sha256-4HLtjeVgH0eIB3aZ9mLYF6E8oU5chNdjU6p6rrXpl9U=" crossorigin="anonymous"></script>
  58. <!-- NOTICE: Different versions of Fuse.js provide different search results -->
  59. <!-- I have tried multiple version and choose this version for its results. Other versions have different sorting algorithms or may not work well with Vietnamese (maybe other languages too?) -->
  60. <!-- If you satisfy with the result, please don't change the version of Fuse.js here. -->
  61. <script src="https://cdn.jsdelivr.net/npm/fuse.js@3.6.1/dist/fuse.min.js"></script>
  62. <script src="{{ "js/search.js" | absURL }}"></script>
  63. </article>
  64. </div>
  65. {{ end }}