Skip to content

feat(theme-search-algolia): allow overriding transformSearchClient#11581

Merged
slorber merged 2 commits intofacebook:mainfrom
hugohaggmark:hugoh/pass-transformSearchClient-in-props
Dec 5, 2025
Merged

feat(theme-search-algolia): allow overriding transformSearchClient#11581
slorber merged 2 commits intofacebook:mainfrom
hugohaggmark:hugoh/pass-transformSearchClient-in-props

Conversation

@hugohaggmark
Copy link
Copy Markdown
Contributor

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

See #11580

Test Plan

  1. add algolia search config
  2. swizzle @docusaurus/theme-search-algolia and choose to Wrap the component
  3. Pass a custom transformSearchClient function
  4. Perform a search
  5. Verify that the custom transformSearchClient function should be called

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

Closes #11580

@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Nov 28, 2025

Hi @hugohaggmark!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@netlify
Copy link
Copy Markdown

netlify bot commented Nov 28, 2025

[V2]

Name Link
🔨 Latest commit b625a0e
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6933120cc7d15e0008d6d30a
😎 Deploy Preview https://deploy-preview-11581--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Nov 28, 2025
@meta-cla
Copy link
Copy Markdown

meta-cla bot commented Nov 28, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Copy link
Copy Markdown
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that could be convenient for some advanced use-cases

Ideally we'd need to split this large legacy component into many smaller parts

}

export default function SearchBar(): ReactNode {
export default function SearchBar(props: Partial<DocSearchV4Props>): ReactNode {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the prop type more permissive so that we can override everything (at your own risk)

const docSearchProps: DocSearchV4Props = {
...(siteConfig.themeConfig.algolia as DocSearchV4Props),
// Let props override theme config
// See https://github.com/facebook/docusaurus/pull/11581
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful comment to remember the purpose

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Dec 5, 2025
@slorber slorber merged commit 616dec1 into facebook:main Dec 5, 2025
44 of 45 checks passed
@hugohaggmark
Copy link
Copy Markdown
Contributor Author

Thanks @slorber for getting this merged 🙌 . Do you have an idea of when this might be released?

@slorber
Copy link
Copy Markdown
Collaborator

slorber commented Dec 8, 2025

Likely before the end of the year

But you can use today with a canary: https://docusaurus.io/community/canary

@hugohaggmark
Copy link
Copy Markdown
Contributor Author

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass custom transformSearchClient to a swizzled but Wrapped SearchBar

2 participants