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

refactor(theme-common): move useDocsPreferredVersion() to public api #7729

Merged
merged 1 commit into from Jul 6, 2022

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jul 6, 2022

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

useDocsPreferredVersion() is a useful hook to get the currently "selected" version (ie the one displayed in the navbar dropdown)

It is complicated to implement in userland and already used by some plugins (see also easyops-cn/docusaurus-search-local#205 (comment))

So let's move this to our public undocumented API: we maintain retro compatibility on all minor versions

Test Plan

CI + preview

Test links

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

Related issues/PRs

@slorber slorber added the pr: internal This PR does not touch production code, or is not meaningful enough to be in the changelog. label Jul 6, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 6, 2022
@netlify
Copy link

netlify bot commented Jul 6, 2022

[V2]

Name Link
🔨 Latest commit 707da58
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/62c5ac9ba5c4d70008f2f8e2
😎 Deploy Preview https://deploy-preview-7729--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.

@github-actions
Copy link

github-actions bot commented Jul 6, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟢 90 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 82 🟢 100 🟢 100 🟢 100 🟢 90 Report

@Josh-Cena
Copy link
Collaborator

My take on this: if we make useDocsPreferredVersion public, we should do so for useLayoutDoc as well. I've found that to be more useful (and we do use it ourselves)

@github-actions
Copy link

github-actions bot commented Jul 6, 2022

Size Change: 0 B

Total Size: 800 kB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.6 kB
website/build/assets/css/styles.********.css 106 kB
website/build/assets/js/main.********.js 602 kB
website/build/index.html 38.9 kB

compressed-size-action

@slorber
Copy link
Collaborator Author

slorber commented Jul 6, 2022

We'll consider other internal apis to move to public in separate PRs

@slorber slorber merged commit bc0538f into main Jul 6, 2022
@slorber slorber deleted the slorber/public-useDocsPreferredVersion branch July 6, 2022 15:58
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: internal This PR does not touch production code, or is not meaningful enough to be in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants