|
33 | 33 | {% endif %} |
34 | 34 | <i class="fa-solid fa-magnifying-glass"></i> |
35 | 35 | <!-- Include the MeiliSearch JavaScript library for the search bar --> |
36 | | - <script src="https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.js"></script> |
| 36 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script> |
37 | 37 |
|
38 | 38 | {% if not theme_use_meilisearch.host %} {% set HOST_URL = |
39 | 39 | "https://backend.search.pyansys.com/" %} {% else %} {% set HOST_URL = |
40 | 40 | theme_use_meilisearch.host %} {% endif %} |
41 | | - |
42 | 41 | <script> |
43 | | - document.body.style.overflow = "hidden !important"; |
44 | | - // Initialize the MeiliSearch bar with the given API key and host |
45 | | - // inspect the first value of index UID as default |
46 | | - var theSearchBar = docsSearchBar({ |
47 | | - hostUrl: "{{ HOST_URL }}", |
48 | | - apiKey: "{{ API_KEY }}", |
49 | | - indexUid: "{{ theme_use_meilisearch.index_uids.items()|first|first }}", |
50 | | - inputSelector: "#search-bar-input", |
51 | | - debug: true, // Set debug to true if you want to inspect the dropdown |
52 | | - meilisearchOptions: { |
53 | | - limit: 1000, |
54 | | - }, |
55 | | - }); |
56 | | - |
57 | | - // Listen for changes in the dropdown selector and update the index uid and suggestion accordingly |
58 | | - document |
59 | | - .getElementById("indexUidSelector") |
60 | | - .addEventListener("change", function () { |
61 | | - theSearchBar.indexUid = this.value; |
62 | | - theSearchBar.suggestionIndexUid = this.value; |
63 | | - theSearchBar.autocomplete.autocomplete.setVal(""); |
64 | | - }); |
65 | | - |
66 | | - // Listen for changes in the search bar input and update the suggestion accordingly |
67 | | - document |
68 | | - .getElementById("search-bar-input") |
69 | | - .addEventListener("change", function () { |
70 | | - theSearchBar.suggestionIndexUid = |
71 | | - document.getElementById("indexUidSelector").value; |
72 | | - }); |
73 | | - |
74 | | - // Set the focus on the search bar input |
75 | | - document.getElementById("searchbar").focus(); |
76 | | - |
77 | | - // Set the focus on the dropdown selector |
78 | | - document |
79 | | - .getElementById("searchbar") |
80 | | - .addEventListener("indexUidSelector", function () { |
81 | | - theSearchBar.autocomplete.autocomplete.close(); |
82 | | - }); |
| 42 | + var HOST_URL = "{{ HOST_URL }}"; |
| 43 | + var API_KEY = "{{ API_KEY }}"; |
| 44 | + var indexUid = "{{ theme_use_meilisearch.index_uids.items()|first|first }}"; |
83 | 45 | </script> |
| 46 | + |
| 47 | + <script src="{{ pathto('_static/js/meilisearch_theme_wrap.js', 1) }}"></script> |
84 | 48 | </form> |
85 | 49 | {% else %} |
86 | 50 | <!-- If there is no MiliSearch enabled, use the PyData search --> |
|
0 commit comments