Skip to content

Docs: add search integration to Zensical #12605

@humitos

Description

@humitos

We have a similar section in our MkDocs documentation, but I wasn't able to find how to disable the native search on Zensical and it triggers both modals, which is annoying.

Configure Read the Docs search
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To configure your site to use :doc:`Read the Docs search </server-side-search/index>` instead of the default search:

#. Add the following block of JavaScript:

    .. code-block:: js
        :caption: assets/javascript/readthedocs.js

        document.addEventListener("DOMContentLoaded", function(event) {
        // Trigger Read the Docs' search addon instead of Zensical default
        document.querySelector(".md-search").addEventListener("click", (e) => {
                const event = new CustomEvent("readthedocs-search-show");
                document.dispatchEvent(event);
            });
        });

#. Include ``assets/javascript/readthedocs.js`` in your MkDocs configuration:

    .. code-block:: toml
        :caption: zensical.toml

        [project]
        extra_javascript = ["assets/javascript/readthedocs.js"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions