-
In #6729, the old TOC splicing behavior We use this function to split the TOC into a few parts, with some additional text inbetween. Is there any way to achieve this behavior now? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
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 |
Beta Was this translation helpful? Give feedback.
-
Thank you for the proposal! This solves our problem. We want to group the TOC into "sections" and add some text before each such "section":
We can do this with the slice-approach you suggested; It is a bit fragile, but we can live with that. |
Beta Was this translation helpful? Give feedback.
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:
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