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: make MDX export a flat TOC list instead of tree #6729

Merged
merged 3 commits into from
Feb 23, 2022

Conversation

Josh-Cena
Copy link
Collaborator

@Josh-Cena Josh-Cena commented Feb 21, 2022

Breaking change

  • The props received by TOCItems have changed. You may need to re-swizzle TOCItems. Good news is, TOC, TOCCollapsible, etc. don't need to be changed.
  • The documented behavior of splicing TOC headings through toc={[toc[2], toc[4]]} has been removed. If you previously used TOCInline but treated toc as an opaque data structure (only passing it as toc={toc}, you are safe; but if you relied on its tree structure properties, you may need to implement your own helper function to select all the wanted headings.

@slorber Do you think we should provide this helper function ourselves? Something like useTOCNodes([2, 4]). We may even allow a prop callback: filterTOC={(tocTree) => [toc[2], toc[4]]} which gets called after the TOC has been treeified. It would not be hard to build, just unsure of the value.

Motivation

This is a necessary step to work on #3915. See also #6201.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Made more tests

@Josh-Cena Josh-Cena added the pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. label Feb 21, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Feb 21, 2022
@netlify
Copy link

netlify bot commented Feb 21, 2022

✔️ [V2]

🔨 Explore the source changes: c8f0faa

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/62131f209850e9000797a761

😎 Browse the preview: https://deploy-preview-6729--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Feb 21, 2022

⚡️ Lighthouse report for the changes in this PR:

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

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

@github-actions
Copy link

github-actions bot commented Feb 21, 2022

Size Change: +478 B (0%)

Total Size: 782 kB

Filename Size Change
website/build/assets/js/main.********.js 590 kB +478 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 48 kB
website/build/assets/css/styles.********.css 106 kB
website/build/index.html 37.6 kB

compressed-size-action

@Josh-Cena Josh-Cena added the status: awaiting review This PR is ready for review, will be merged after maintainers' approval label Feb 22, 2022
@slorber
Copy link
Collaborator

slorber commented Feb 23, 2022

Thanks, LGTM 👍

Couldn't see any issue even on weird page like this one:

https://deploy-preview-6729--docusaurus-2.netlify.app/tests/docs/toc/toc-test-bad/
https://docusaurus.io/tests/docs/toc/toc-test-bad/


Let's wait for users to complain before implementing anything extra that maybe nobody needs

@slorber slorber merged commit c3370be into main Feb 23, 2022
@slorber slorber deleted the jc/refactor-toc branch February 23, 2022 14:12
@Josh-Cena Josh-Cena removed the status: awaiting review This PR is ready for review, will be merged after maintainers' approval label Feb 23, 2022
ISSOtm added a commit to gbdev/rgbds-www that referenced this pull request Apr 19, 2024
Until Docusaurus 2.0.0-beta16, the ToC was a tree structure;
since facebook/docusaurus#6729, it is flat instead.
The mismatch caused level 3 headings not to appear in the ToC.
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