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

feat(v2): persist docs preferred version #3543

Merged
merged 13 commits into from
Oct 12, 2020

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Oct 6, 2020

Motivation

Problem:

The versions dropdown is reset to latest version (currently 2.0.0-alpha.66 (unreleased)).

If the user choose to use a specific version, we can persist in local storage that choice so that the dropdown version does not "jump" from one version to the other.

We shouldn't treat the stored value as "safe" because it can be stale and return outdated versionName that is not part of the site anymore, so it's a best effort only.

Asked by @Simek as a possible enhancement to RN website.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

preview

@slorber slorber requested a review from lex111 as a code owner October 6, 2020 13:02
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 6, 2020
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Oct 6, 2020

Deploy preview for docusaurus-2 ready!

Built with commit d9c4d9b

https://deploy-preview-3543--docusaurus-2.netlify.app

@slorber slorber marked this pull request as draft October 6, 2020 13:09
@slorber
Copy link
Collaborator Author

slorber commented Oct 6, 2020

TODO before merge:

  • use a DocsPreferredVersionProvider at the top of the theme, so that persisted state is shared between all usages (currently each hook usage duplicates that state locally)
  • If we land on a v 1.0 page from google, should we persist 1.0 as the preferred version to browse?
  • behavior of the contextual search regarding which version we search into when we are on unversioned pages (related to Contextual doc version search (Algolia/DocSearch) #3396)

@slorber slorber marked this pull request as ready for review October 9, 2020 16:31
@slorber
Copy link
Collaborator Author

slorber commented Oct 9, 2020

@lex111 if you're interested to review, this works locally but just need to figure out why Netlify is not happy 😅

This feature was harder than I thought, but worth investing in it. Will likely use it for knowing which version to search in while browsing the homepage etc, for #3550

import {useDocsData} from '@theme/hooks/useDocs';

// TODO why this import does not work!
// import {DEFAULT_PLUGIN_ID} from '@docusaurus/constants';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no idea why, but unable to make this work

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Oct 12, 2020
@slorber slorber merged commit 4130f1a into master Oct 12, 2020
@slorber slorber deleted the slorber/persist-docs-preferred-version branch August 17, 2021 17:57
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: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants