Skip to content

TOC customization changed in 2.0.0-beta.16 #6962

Answered by slorber
mbj4668 asked this question in General
Discussion options

You must be logged in to vote

Yes, the TOC was refactored from a tree structure to a flat array structure, but you can still filter it to create a slice of that TOC array

One example:

- <TOCInline toc={toc[toc.length - 1].children}/>
+ <TOCInline toc={toc.slice(2)} />

See also jestjs/jest#12500 (comment)


Note: if your toc transformations are complex and not easy to inline in MDX, you can build your own helper to filter this TOC.

Eventually, we could add these utils to Docusaurus but for that we'd need much more info about your use-case and see if other users are presenting a similar use-case to design a good API

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by slorber
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants