fix(search-algolia): pass custom transformItems function to SearchBar#8462
fix(search-algolia): pass custom transformItems function to SearchBar#8462slorber merged 2 commits intofacebook:mainfrom
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
| props.transformItems | ||
| ? props.transformItems | ||
| : (items) => | ||
| items.map((item) => { | ||
| // If Algolia contains a external domain, we should navigate without | ||
| // relative URL | ||
| if (isRegexpStringMatch(externalUrlRegex, item.url)) { | ||
| return item; | ||
| } | ||
|
|
||
| // We transform the absolute URL into a relative URL. | ||
| const url = new URL(item.url); | ||
| return { | ||
| ...item, | ||
| url: withBaseUrl(`${url.pathname}${url.hash}`), | ||
| }; | ||
| }), |
There was a problem hiding this comment.
Extract the arrow to a new variable and write useRef(props.transformItems ?? defaultTransformItems).
|
This PR references itself (instead of an external issue) and does not really give much context into what you are trying to achieve (although I have an idea, I'd like you to explain) This is also doing to conflict with #8428, which may already solve your use-case? Note: make sure your use-case also works on the SearchPage? https://docusaurus.io/search |
|
Found the original issue 🤪 #8461 Using a wrapper to provide a custom transformItems prop is exactly what I had in mind, so feel free to go ahead. Still wonder if the newly introduced code does not solve your use-case? cf #8428 Why do you want to transform those items? |
# Conflicts: # packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.tsx
|
Sorry @slorber @Josh-Cena. I was on a Christmas holiday but seems like you guys took care of this PR already.
Oops, my bad.
Not really. I wanted to tweak the search results and reorder them the way I want. The linked issue allows only changing the results pathname if I could understand correctly. |
…#8462) Co-authored-by: sebastienlorber <[email protected]> closes undefined Closes #8462 Closes #8461
Pre-flight checklist
Motivation
Closes #8462
Test Plan
Manual
Test links
Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/
Related issues/PRs
Closes #8461