-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Configure table-of-contents heading levels (h2, h3, h4...) #2700
Comments
Hey @hhk7734 I appreciate your suggestion, but I don't know if make sense allows the TOC in every level of Heading. The goal of the TOC is set highlights for sections, if you put a Head like |
Hi @fanny |
I think this will be a useful feature, definitely we need it. However, the algorithm presented in the issue does not seem reliable, we need to work on a better solution. PR as always welcome. Similar issue on Canny - https://docusaurus.canny.io/admin/board/feature-requests/p/configuration-option-for-table-of-content |
A workaround to make it configurable per doc is to use the suggest plugin above and configure via first comment in document.
const plugin = (options = {}) => {
const name = options.name || 'toc';
const transformer = (node) => {
// Because frontmatter is not passed along we must use comments instead for config.
const firstComment = node.children.find(node => node.type === 'comment')
let config = {}
if (firstComment) {
config = require('json5').parse(firstComment.value)
}
// -- Have to use hacky comments because frontmatter is inaccessible. See: #3935 |
This feature would be very much appreciated for documentation regarding nested objects, such as a complex JSON schema. |
This feature would help new electron docs. |
💥 Proposal
(A clear and concise description of what the proposal is.)
Have you read the Contributing Guidelines on issues?
I read the issue side.
Docs: ToC is created using only
<h2>
and<h3>
.After changing
node_modules/@docusaurus/mdx-loader/src/remark/rightToc/search.js
with the code below and setting minDepth and maxDepth, Users can display the ToC in the desired range.
This code has only been tested on my page. I am not familiar with javascript and I always write docs from
<h1>
(#). So I'm not sure if the code below is ok.The text was updated successfully, but these errors were encountered: