kai687 / sphinxawesome-theme

Create beautiful and awesome websites with the Sphinx documentation generator.
https://sphinxawesome.xyz
MIT License
114 stars 29 forks source link

Integrating Custom Elasticlunr Search with Popup Display #1987

Closed sachin-suresh-rapyuta closed 2 months ago

sachin-suresh-rapyuta commented 2 months ago

I'm attempting to integrate Elasticlunr search into the Sphinx Awesome theme and display the search results in a popup, similar to how Algolia DocSearch functions. While I have successfully integrated the search functionality, I am facing difficulties in getting the search results to appear in a popup on the same page, without redirecting to a separate search.html page.

Note: I cannot use Algolia as our doc site is private.

Steps Taken:

  1. Implemented Elasticlunr search with custom search.js and search.html files.
  2. Attempted to follow the theme's guidelines for customizing templates, but the popup doesn't appear when clicking on the search input.
  3. Instead, the search redirects to the search.html page where another search input appears, which isn't the desired behavior.

Actual Behavior:

Request:

It would be beneficial to have documentation or guidance on how to correctly integrate a custom search, like Elasticlunr, into the Sphinx Awesome theme, particularly for achieving a seamless popup-based search experience. Any insights or recommendations would be greatly appreciated.

kai687 commented 2 months ago

I have no experience with Elasticlunr, but here's what I do know:

You need to get rid of the form action='search.html' that submits the form to open the Search results page with the entered search query. You could do this by customizing the searchbox.html template. For more information, see Add custom templates.

sachin-suresh-rapyuta commented 2 months ago

Thanks @kai687. I was able to successfully integrate Elasticlunr with some customizations.