Class: DocsKit::SearchController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- DocsKit::SearchController
- Defined in:
- app/controllers/docs_kit/search_controller.rb
Overview
Serves the docs search — one gem controller, host-drawn route (same shape as DocsKit::LlmsController; the engine is glue-only and adds no routes):
# config/routes.rb
get "/docs/search" => "docs_kit/search#index"
#index answers BOTH formats off the same index:
* html — the JS-off path: renders DocsUI::SearchResults inside DocsUI::Shell,
a full working results page. The topbar form (GET ?q=) lands here.
* json — the enhancement path: the docs-nav palette fetches `search.json?q=`
debounced and renders the hits client-side. The form still submits to the
html path if JS dies mid-typing.
The index is built lazily per request from DocsKit::SearchIndex, whose entries
come from each registry page's Markdown twin (DocsKit::MarkdownExport) split on
its ## headings — the SAME twins llms-full.txt serves, so search can never
drift from the pages. Sites are tens of pages; there's no external index, no
build step, no second registry.
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/docs_kit/search_controller.rb', line 31 def index hits = search_index.search(query) respond_to do |format| format.html { render_results_page(hits) } format.json { render json: { "query" => query, "results" => hits.map(&:as_json) } } end end |