Skip to content

Commit

Permalink
Add a doc for how to integrate search without other customization (#1…
Browse files Browse the repository at this point in the history
…1984)

We had a user asking about this,
so pulled it from the Mkdocs example to the high-level Addons docs.


<!-- readthedocs-preview docs start -->
---
:books: Documentation previews :books:

- User's documentation (`docs`):
https://docs--11984.org.readthedocs.build/en/11984/

<!-- readthedocs-preview docs end -->

<!-- readthedocs-preview dev start -->
- Developer's documentation (`dev`):
https://dev--11984.org.readthedocs.build/en/11984/

<!-- readthedocs-preview dev end -->
  • Loading branch information
ericholscher authored Feb 10, 2025
1 parent 2859ec8 commit 1bcd53d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/user/addons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@ Individual configuration options for each addon are available in :guilabel:`Sett
#. In the left bar, go to :guilabel:`Addons`.
#. Configure each Addon individually.

Integrating with Addons
-----------------------

Integrate with Search as you type
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To configure your site to use :doc:`Read the Docs search </server-side-search/index>` instead of the default search, adapt the following block of JavaScript to your own site:

.. code-block:: js
:caption: javascript/readthedocs.js
// TODO: Change me if needed
const selector = "input[type='search']";
document.addEventListener("DOMContentLoaded", function(event) {
// Trigger Read the Docs' search addon instead of the default search
document.querySelector(selector).addEventListener("click", (e) => {
const event = new CustomEvent("readthedocs-search-show");
document.dispatchEvent(event);
});
});
.. note:: Depending on the tool you are using,
you may need to change the selector to match the search input field.
You will also need to ensure that the JavaScript file is included in your documentation build.

Addons data and customization
-----------------------------

Expand Down

0 comments on commit 1bcd53d

Please sign in to comment.