feat: floating Table of Contents #1440
Draft
+401
−32
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.
Hello, this PR replaces the static ToC widget at the top of a page with a floating, persistent navigation panel that follows users as they scroll through documents. I did touch the original ToC code so please have a good look :)
Note Let me know if this is better suited as a plugin… putting it as draft as I noticed some weird behavior with widgets being killed 'randomly' jumping to different AST sections.
Rationale: You can quickly jump through the document without having to scroll back to the top.
Implementation
widgets.toc()
withwidgets.floatingToc()
web/styles/main.scss
classes)class="sb-lua-top-widget"
) via.toc-hidden-container
class, which might not be the best solutiondisableTOC
frontmatter as built on top of existing implementation, but it is now a string property. I've kept the property name for legacy purposes, but would have preferreddisplayTOC = true|false|always
Possible enhancements
Before

After

(peeking but not hovered; deliberately barely visible;
disableTOC: false|never
)(hovered)

(mobile)
