docs: update Gurubase widget to handle SPA navigation #903
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
The Gurubase widget only initializes on initial page load. When navigating within the Docusaurus SPA (Single Page Application):
/) or other pages to docs (/docs/...) does not show the widgetThis happens because Docusaurus uses client-side routing, and the widget initialization only runs once on page load, not on route changes.
What is the new behavior?
The widget now properly handles SPA navigation:
Implementation details:
initWidget()anddestroyWidget()functions with proper cleanuppushState,replaceState) to detect route changespopstateevent listener for browser navigationfixes (issue)
Notes for reviewers
Summary by cubic
Make the Gurubase widget handle SPA navigation in Docusaurus so it appears on /docs pages and is removed elsewhere. Fixes missing widget after in-app navigation and stale widget when leaving docs, including back/forward.
Written for commit fc4b5d1. Summary will update on new commits.