docsearch
docsearch copied to clipboard
Invoke search overlay with a simple link
I have the searchbox working on my pages.
Is it possible to also invoke the search overlay with a simple link in my body texts, without automatically creating the whole searchbox html at that position?
I don't see any options for the docsearch() function to use for that. Actually what command-K does, but working on a click instead of a keyboard event.
If this is not possible, I'd like to put this in as a feature request.
Is it possible to also invoke the search overlay with a simple link in my body texts, without automatically creating the whole searchbox html at that position?
Sure, you can re-implement the DocSearch component on your side by providing your own DocSearchButton
Ok, clear, however I am currently using docseach-js as simple as possible, without a package manager. I was hoping there would be an (undocumented) way to use docsearch()
or another invoking function I can add to use a text link to open the overlay, without it creating the whole searchbox.
Not pretty, but works:
<a href="javascript:document.getElementsByClassName('DocSearch-Button')[0].click()">Search</a>
@wilhelmer thanks, that works nicely!