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-classic): move all sidebar-related config under themeConfig.docs.sidebar #7277

Merged
merged 1 commit into from
May 4, 2022

Conversation

Josh-Cena
Copy link
Collaborator

@Josh-Cena Josh-Cena commented Apr 30, 2022

Breaking changes

Nothing complicated to upgrade, and validation errors will tell you what to do:

  • themeConfig.hideableSidebar has been moved to themeConfig.docs.sidebar.hideable
  • themeConfig.autoCollapseSidebarCategories has been moved to themeConfig.docs.sidebar.autoCollapseCategories

So if you previously had:

const config = {
  themeConfig: {
    hideableSidebar: true,
    autoCollapseSidebarCategories: true,
  },
};

Change it to:

const config = {
  themeConfig: {
    docs: {
      sidebar: {
        hideable: true,
        autoCollapseCategories: true,
      },
    },
  },
};

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

We are having more and more theme config options that are at the root. To make things more scalable in the future, I propose to namespace them all under docs.sidebar.

Test Plan

Added two tests to verify that validation schema works.

@Josh-Cena Josh-Cena added the pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. label Apr 30, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 30, 2022
@@ -104,6 +104,10 @@ export type TableOfContents = {
export type ThemeConfig = {
docs: {
versionPersistence: DocsVersionPersistence;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This API is, AFAIK, undocumented. Is it intended for usage by anyone? I initially thought about docsSidebar so there's some degree of parallel with navbar and footer, but because of the existence of this field, I eventually put it in docs.sidebar, with one extra level of nesting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should likely document versionPersistence, implemented in #3543

Note some sites may want to minimize the usage of local storage. But it may have been me misinterpreting the GDPR rules and may not be that useful to provide an option for it 🤷‍♂️


Nesting docs.sidebar doesn't look like a bad idea anyway, still related to preemptive pluralization 🤪

@netlify
Copy link

netlify bot commented Apr 30, 2022

[V2]

Name Link
🔨 Latest commit d95c2e2
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/626d16561461df0009a36487
😎 Deploy Preview https://deploy-preview-7277--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

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 44
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

Lighthouse ran on https://deploy-preview-7277--docusaurus-2.netlify.app/

@github-actions
Copy link

Size Change: -4 B (0%)

Total Size: 806 kB

ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 50.7 kB 0 B
website/build/assets/css/styles.********.css 107 kB 0 B
website/build/assets/js/main.********.js 610 kB -4 B (0%)
website/build/index.html 38.8 kB 0 B

compressed-size-action

@Josh-Cena Josh-Cena changed the title refactor(theme-classic): move all sidebar-related config options to docs.sidebar refactor(theme-classic): move all sidebar-related config under themeConfig.docs.sidebar Apr 30, 2022
@Josh-Cena Josh-Cena added the status: awaiting review This PR is ready for review, will be merged after maintainers' approval label May 2, 2022
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

👍 looks like a nice improvement to do

@@ -104,6 +104,10 @@ export type TableOfContents = {
export type ThemeConfig = {
docs: {
versionPersistence: DocsVersionPersistence;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should likely document versionPersistence, implemented in #3543

Note some sites may want to minimize the usage of local storage. But it may have been me misinterpreting the GDPR rules and may not be that useful to provide an option for it 🤷‍♂️


Nesting docs.sidebar doesn't look like a bad idea anyway, still related to preemptive pluralization 🤪

@slorber slorber merged commit 785fed7 into main May 4, 2022
@slorber slorber deleted the jc/namespace-docs-sidebar-options branch May 4, 2022 10:08
@Josh-Cena Josh-Cena removed the status: awaiting review This PR is ready for review, will be merged after maintainers' approval label May 4, 2022
s4dr0t1 added a commit to s4dr0t1/s4dr0t1.github.io that referenced this pull request Jun 21, 2022
@ghost ghost mentioned this pull request Mar 3, 2023
2 tasks
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: breaking change Existing sites may not build successfully in the new version. Description contains more details.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants