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

fix(core): preload should support encoded page links #7977

Merged

Conversation

adventure-yunfei
Copy link
Contributor

@adventure-yunfei adventure-yunfei commented Aug 19, 2022

Motivation

Similar to #4407, when containing encoded chars (like whitespace, cn) "preload" won't work, and thus the page will blink (first render as static html, then empty, then after js loaded async render page again), and break the behavior that jumping to doc content with url hash #.

Test Plan

Wish to provide unit test, but stuck during initializing dev env. The code is simple, and is tested in my own repo.

A playground to show the problem: https://codesandbox.io/s/frosty-curran-rsoubc?file=/docs/%E5%85%A5%E9%97%A8%E4%BB%8B%E7%BB%8D.md. Visit /docs/入门介绍 and debug client/preload.js file. preload func won't match the extract route.

Test links

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

Related issues/PRs

#4407

@facebook-github-bot
Copy link
Contributor

Hi @adventure-yunfei!

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 cla@fb.com. Thanks!

@netlify
Copy link

netlify bot commented Aug 19, 2022

[V2]

Name Link
🔨 Latest commit 98957bb
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/63075d3387c8c7000943fa32
😎 Deploy Preview https://deploy-preview-7977--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 site settings.

@@ -7,6 +7,7 @@

import routes from '@generated/routes';
import {matchRoutes} from 'react-router-config';
import { uniq } from 'lodash';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is client code. Please hand-roll your implementation (should be fairly trivial)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

checked the component.preload implementation, uniq is not necessary. preload won't actually run twice.

@adventure-yunfei adventure-yunfei force-pushed the fix/preload-with-encoded-page-links branch from 61ebe60 to 021158a Compare August 19, 2022 04:28
@github-actions
Copy link

github-actions bot commented Aug 19, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 83 🟢 98 🟢 100 🟢 100 🟠 80 Report
/docs/installation 🟠 73 🟢 100 🟢 100 🟢 100 🟢 90 Report

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 19, 2022
@facebook-github-bot
Copy link
Contributor

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

1 similar comment
@facebook-github-bot
Copy link
Contributor

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

Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
@slorber slorber changed the title fix: preload with encoded page links fix(core): preload with encoded page links Aug 25, 2022
@slorber slorber changed the title fix(core): preload with encoded page links fix(core): preload should support encoded page links Aug 25, 2022
@slorber slorber added pr: bug fix This PR fixes a bug in a past release. to backport This PR is planned to be backported to a stable version of Docusaurus labels Aug 25, 2022
@slorber slorber merged commit 75dc4a4 into facebook:main Aug 25, 2022
slorber added a commit that referenced this pull request Sep 1, 2022
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
@slorber slorber added backported This PR has been backported to a stable version of Docusaurus and removed to backport This PR is planned to be backported to a stable version of Docusaurus labels Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR has been backported to a stable version of Docusaurus CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants