|
12 | 12 | <script src="https://houselearning.github.io/home/main.js"></script> |
13 | 13 | <script src="https://cdn.tailwindcss.com"></script> |
14 | 14 | <script src="/cookiebanner.js"></script> |
| 15 | + <script src="/docs/search.js"></script> |
15 | 16 | <!-- Configure Tailwind for Inter font and custom colors --> |
16 | 17 | <script> |
17 | 18 | tailwind.config = { |
@@ -178,58 +179,7 @@ <h2 class="text-2xl font-bold text-gray-900 mb-3">Can't Find What You Need?</h2> |
178 | 179 | </div> |
179 | 180 | </footer> |
180 | 181 | <script> |
181 | | - let docsData = []; |
182 | | - |
183 | | - // Fetch docs.json on page load |
184 | | - fetch("/docs/docs.json") |
185 | | - .then(res => res.json()) |
186 | | - .then(data => docsData = data) |
187 | | - .catch(err => console.error("Failed to load docs.json:", err)); |
188 | | - |
189 | | - const input = document.getElementById("docsSearchInput"); |
190 | | - const resultsBox = document.getElementById("docsSearchResults"); |
191 | | - |
192 | | - input.addEventListener("input", () => { |
193 | | - const q = input.value.trim().toLowerCase(); |
194 | | - |
195 | | - if (q.length === 0) { |
196 | | - resultsBox.classList.add("hidden"); |
197 | | - resultsBox.innerHTML = ""; |
198 | | - return; |
199 | | - } |
200 | | - |
201 | | - const matches = docsData.filter(item => |
202 | | - item.title.toLowerCase().includes(q) || |
203 | | - (item.description && item.description.toLowerCase().includes(q)) |
204 | | - ); |
205 | | - |
206 | | - if (matches.length === 0) { |
207 | | - resultsBox.innerHTML = ` |
208 | | - <div class="p-4 text-sm text-gray-500">No results found.</div> |
209 | | - `; |
210 | | - resultsBox.classList.remove("hidden"); |
211 | | - return; |
212 | | - } |
213 | | - |
214 | | - resultsBox.innerHTML = matches |
215 | | - .map(item => ` |
216 | | - <a href="${item.link}" |
217 | | - class="block p-4 border-b last:border-b-0 border-gray-100 hover:bg-gray-50 transition rounded-lg"> |
218 | | - <div class="font-semibold text-gray-900">${item.title}</div> |
219 | | - <div class="text-sm text-gray-600">${item.description || ""}</div> |
220 | | - </a> |
221 | | - `) |
222 | | - .join(""); |
223 | | - |
224 | | - resultsBox.classList.remove("hidden"); |
225 | | - }); |
226 | | - |
227 | | - // Click-away close |
228 | | - document.addEventListener("click", (e) => { |
229 | | - if (!resultsBox.contains(e.target) && e.target !== input) { |
230 | | - resultsBox.classList.add("hidden"); |
231 | | - } |
232 | | - }); |
| 182 | + |
233 | 183 | </script> |
234 | 184 |
|
235 | 185 | </body> |
|
0 commit comments