Open pimterry opened 4 years ago
the same problem
@haritonasty in the end, I use this plugin to globally inject the docsearch script & manage all that and then I use my own component to create each search input & activate it, which works. You can see the component source here: https://github.com/httptoolkit/httptoolkit.tech/blob/master/src/components/docsearch.jsx.
There's probably better ways to do this, but it's working well enough for me for now.
@pimterry thank you very much for saving my day 🤗
Because this plugin only runs once, it breaks if you have a search box that isn't on every single page (e.g. in the header), as it never spots new search boxes that appear later.
When you first load the page with the search box it's ok, but if you go to another page without the search box and then go back, your search won't work. This is because Gatsby turns all those page transitions into JS transformations instead of real page loads.