Skip to content
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

perf(v2): algolia search result no longer cause full page refresh #2079

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

endiliey
Copy link
Contributor

@endiliey endiliey commented Dec 3, 2019

Motivation

Use client side navigation, avoid full page refresh on algolia search result. The extra benefit is also pretty rad, local dev can work nicely now. Previously it will always go to v2.docusaurus.io/xxxx

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

Before
Try https://v2.docusaurus.io/ and search anything. It will cause page refresh

After
Also still in localhost
no page refresh

@endiliey endiliey added the pr: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient. label Dec 3, 2019
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-2 ready!

Built with commit ea54588

https://deploy-preview-2079--docusaurus-2.netlify.com

@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit ea54588

https://deploy-preview-2079--docusaurus-preview.netlify.com

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 3, 2019
// Algolia use closest parent element id #__docusaurus when a h1 page title does not have an id
// So, we can safely remove it. See https://github.com/facebook/docusaurus/issues/1828 for more details.
const routePath =
`#__docusaurus` === a.hash
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didnt want to do replace() because thats not supported in older browser and will have to be polyfilled :v

Copy link
Contributor

@yangshun yangshun left a comment

Choose a reason for hiding this comment

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

This is so cool! Is there a handleHover? Then we can preload when they are hovering LOL. I'm not very used to seeing the bar at the top now.

@yangshun yangshun merged commit dd6b10d into master Dec 4, 2019
@endiliey
Copy link
Contributor Author

endiliey commented Dec 4, 2019

cc @s-pace for docsearch full api.

@endiliey endiliey deleted the endi/algolia-norefresh branch December 6, 2019 05:37
@s-pace
Copy link

s-pace commented Dec 6, 2019

Not easily available in the v2, we will make sure to have it available from the v3.

@endiliey
Copy link
Contributor Author

endiliey commented Dec 6, 2019

@s-pace thanks. By the way what time do DocSearch usually crawl ? So next time I can cut the new version docs just right before it starts to crawl

@s-pace
Copy link

s-pace commented Dec 6, 2019

@endiliey there is no guarantee on the exact time. We can disable the crawl if you want so that it does not broke your search experience during your development.

@endiliey
Copy link
Contributor Author

endiliey commented Dec 6, 2019

@s-pace thank you for the info. The reason why I asked is because usually when I cut a new version of docs for Docusaurus, so there will be a downtime of ~1 day for the search (until it crawl). But i guess its ok :)

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: performance This PR does not add a new behavior, but existing behaviors will be more memory- / time-efficient.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants