feat(search-algolia): algolia externalUrl regex to navigate with window.href - #5795
Conversation
|
✔️ [V2] 🔨 Explore the source changes: ac03ee2 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/617c2ad000377700086e9e9a 😎 Browse the preview: https://deploy-preview-5795--docusaurus-2.netlify.app |
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5795--docusaurus-2.netlify.app/ |
slorber
left a comment
There was a problem hiding this comment.
LGTM, just not a fan of withRegex
63a78a8 to
c033ec9
Compare
| * @param {string} regexAsString | ||
| * @returns { {test: () => boolean }} | ||
| */ | ||
| export function isRegexpStringMatch( |
There was a problem hiding this comment.
I suggest moving this to jsUtils. We shouldn't keep on adding more files, especially for these general-purpose utilities
There was a problem hiding this comment.
imho, it's easier to keep it separated on files for an easier search on the editor. (At least for me)
But as @slorber considers :)
There was a problem hiding this comment.
That really depends on the editor:D Most decent editors allow you to search globally, but navigating in one file is always easier than in a giant directory. If there are more regex tools to come that we can envision, keeping it seperated can be a good idea, but... I'm not sure if there are many painpoints with regex that need utility functions
There was a problem hiding this comment.
I don't care too much about the filename as long as the import name is understandable: it's an implementation detail that we can easily refactor later.
Not a fan of a fn with signature RegExp | {test: () => boolean}, what about returning the boolean and calling test() inside directly?
And "" should not be handled like undefined
There was a problem hiding this comment.
Yep that makes snse to me too, refactored to be much cleaner.
There was a problem hiding this comment.
I would have used a simpler isRegexpStringMatch(regex,str) rather than a higher order function, but it's not too important
| * @param {string} regexAsString | ||
| * @returns { {test: () => boolean }} | ||
| */ | ||
| export function isRegexpStringMatch( |
There was a problem hiding this comment.
I don't care too much about the filename as long as the import name is understandable: it's an implementation detail that we can easily refactor later.
Not a fan of a fn with signature RegExp | {test: () => boolean}, what about returning the boolean and calling test() inside directly?
And "" should not be handled like undefined
c033ec9 to
59ccd9f
Compare
59ccd9f to
d528cc3
Compare
d528cc3 to
d844682
Compare
| regexAsString?: string, | ||
| ): (valueToTest?: string | undefined) => boolean { | ||
| return (valueToTest?: string) => { | ||
| if (!valueToTest || !regexAsString) { |
There was a problem hiding this comment.
hasn't this been reverted? 😅
There was a problem hiding this comment.
Damn, force-pushed with --ammend from another computer and forgot to pull.. doing 30 things at the same time isn't good. Should be fixed now
d844682 to
ac03ee2
Compare
Motivation
Will close #5631, now will be possible to use Algolia native SearchBar with multiple domains on the same Algolia config.
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
docusaurus.config.js:And immediately after, link hrefs will be converted to absolute and will navigate with window.location instead of history.push
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)