Collapsing ToC and ToC Depth Configuration #15
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #14 and then some.
Collapsable ToC
So right now, it defaults to disabled as that's the current implementation. To enable it, you can do so globally by setting
extra.collapse_toc
to true in yourmkdocs.yml
like so:This will enable it site-wide. You can also use page-specific overrides by adding
collapse_toc
to the meta section of your page's markdown like so:This way you can enable/disable it site-wide as well as override it on a page by page basis. You can have it enabled site-wide and disabled on individual pages or have it disabled site-wide and enabled individually as well.
Tunable ToC Depth
The other thing I added since I needed more levels in my ToC was the ability to tune the number of levels shown in the ToC. I used the same pattern as before with the ToC collapsing as well. Here it is via
mkdocs.yml
:And here it is on a page level: