-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
Conversation
✔️ [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 |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6729--docusaurus-2.netlify.app/ |
Size Change: +478 B (0%) Total Size: 782 kB
ℹ️ View Unchanged
|
6561c96
to
c8c287a
Compare
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/ Let's wait for users to complain before implementing anything extra that maybe nobody needs |
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.
Breaking change
TOCItems
have changed. You may need to re-swizzleTOCItems
. Good news is,TOC
,TOCCollapsible
, etc. don't need to be changed.toc={[toc[2], toc[4]]}
has been removed. If you previously usedTOCInline
but treatedtoc
as an opaque data structure (only passing it astoc={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