-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
I'm trying to add custom search tracking to the SearchBar by extending the transformSearchClient function in docusaurus.config.ts but according to https://docusaurus.io/docs/advanced/architecture only serializable values are passed along. So that leaves me with the option to swizzle @docusaurus/theme-search-algolia.
I've swizzled @docusaurus/theme-search-algolia with the command npm run swizzle @docusaurus/theme-search-algolia and then I choose to Wrap the component. Unfortunately there is no way to pass transformSearchClient because this https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.tsx#L315 doesn't pass props to the DocSearch component.
I think it should be possible to pass a custom transformSearchClient to a wrapped SearchBar component because that would allow for fewer breaking changes moving forward.
Reproducible demo
https://stackblitz.com/edit/github-pyvgb77t?file=src%2Ftheme%2FSearchBar%2Findex.tsx
Steps to reproduce
- add algolia search config
- swizzle @docusaurus/theme-search-algolia and choose to Wrap the component
Expected behavior
Be able to pass transformSearchClient as props to SearchBar
Actual behavior
Passed props are ignored
Your environment
- Public source code:
- Public site URL:
- Docusaurus version used:
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
Self-service
- I'd be willing to fix this bug myself.