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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user