docs: add Lunr.js search with fuzzy matching and highlighting

Phase 4 part 1: Add search infrastructure
- Add SearchDoc struct and GenerateSearchIndex to docs handler
- Add stripHTML helper for plain text extraction
- Add ServeSearchIndex endpoint to http handler
- Add /docs/search-index.json route in main.go
- Search index includes all documentation files with ID, title, content, URL
This commit is contained in:
2026-02-02 09:08:37 -05:00
parent 3b3630666a
commit 542fbaf116
5 changed files with 406 additions and 60 deletions
+11
View File
@@ -332,3 +332,14 @@ func (h *HTTPHandler) TryEndpoint(c echo.Context) error {
"message": "API explorer not yet implemented",
})
}
// ServeSearchIndex serves the Lunr.js search index
func (h *HTTPHandler) ServeSearchIndex(c echo.Context) error {
index, err := h.docs.GenerateSearchIndex()
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{
"error": "failed to generate search index",
})
}
return c.JSON(http.StatusOK, index)
}