-
-
Notifications
You must be signed in to change notification settings - Fork 9k
feat(search-algolia): algolia externalUrl regex to navigate with window.href #5795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just not a fan of withRegex
packages/docusaurus-theme-search-algolia/src/theme/utils/index.js
Outdated
Show resolved
Hide resolved
packages/docusaurus-theme-search-algolia/src/validateThemeConfig.js
Outdated
Show resolved
Hide resolved
63a78a8
to
c033ec9
Compare
* @param {string} regexAsString | ||
* @returns { {test: () => boolean }} | ||
*/ | ||
export function isRegexpStringMatch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that makes snse to me too, refactored to be much cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
packages/docusaurus-theme-classic/src/theme/NavbarItem/DefaultNavbarItem.tsx
Outdated
Show resolved
Hide resolved
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasn't this been reverted? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D LGTM
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.)