Repository navigation
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 meta/docusaurus#6729, it is flat instead. The mismatch caused level 3 headings not to appear in the ToC.
…12764) * refactor(theme-common): remove unused internal useTreeifiedTOC hook (AI-assisted) Added with the flat TOC refactor (#6729), but no theme ever used it: themes use useFilteredAndTreeifiedTOC. Only its own test called it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(theme-common): remove unused hook re-exports from /internal (AI-assisted) No package or website code imports useTitleFormatter, useLocationChange, useHistoryPopHandler, useScrollController, useSmoothScrollTo or useHistorySelector from @docusaurus/theme-common/internal. The hooks stay: theme-common uses them internally, and useHistorySelector stays public. useScrollController is now only used in scrollUtils.tsx, so it's no longer exported. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(theme-common): keep exposing useTitleFormatter in /internal (AI-assisted) Some users likely rely on it to format page titles: it's the hook to use alongside TitleFormatterProvider. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Breaking change
TOCItemshave 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 usedTOCInlinebut treatedtocas 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