HotDocs: Search
INFO
Search is currently under development. You can chime in on this GitHub discussion to share wishes and feedback.
HotDocs indexes for search all the pages listed under menu_items
in hotdocs_helper.rb
.
In development, you can index pages by running bundle exec rails hotdocs:lunr:index
.
On production, HotDocs hooks into the assets:precompile
task.
Algolia
To replace the default lunr
search with algolia
, follow these steps:
1 bin/importmap unpin lunr
- Setup Algolia DocSearch
bin/importmap pin @docsearch/js@beta
- Add
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@beta" />
toapp/views/layouts/hotdocs.html.erb
- In
hotdocs_helper.rb
, replace"lunr"
with"algolia"
in#search_provider
- Create the following stimulus controller
bundle exec rails generate stimulus algolia
:import docsearch from "@docsearch/js" import { Controller } from "@hotwired/stimulus" export default class extends Controller { connect() { docsearch({ container: this.element, appId: MY_APP_ID, apiKey: MY_APP_KEY, indexName: MY_INDEX_NAME, // ...https://docsearch.algolia.com/docs/api }); } }