Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks if you have any doc search that isn't on every page #2

Open
pimterry opened this issue Nov 22, 2019 · 3 comments
Open

Breaks if you have any doc search that isn't on every page #2

pimterry opened this issue Nov 22, 2019 · 3 comments

Comments

@pimterry
Copy link

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.

@haritonasty
Copy link

the same problem

@pimterry
Copy link
Author

@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.

@haritonasty
Copy link

@pimterry thank you very much for saving my day 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants