Skip to content

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Aug 27, 2025

This adds dynamic navigation of headers of the current page in the sidebar. This is intended to help the user see what is on the current page, and to be able to more easily navigate it. The "current" header is tracked based on the scrolling behavior of the user, and is marked with a small circle. This includes automatic folding to help keep it from being too unwieldy on a page with a lot of nested headers.

This includes the output.html.sidebar-header-nav option to disable it.

I'm sure there are tweaks, fixes, and improvements that can be made. I'd like to get this out now, and iterate on it over time to make improvements.

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Aug 27, 2025
@shenef
Copy link

shenef commented Aug 27, 2025

As I understand it, this is not supposed to act like a ToC and only shows a few upcoming and previous headers relative to the current scroll point?
Sadly I won't be able to take a look at this for a bit but I'd be curious how this looks like, especially with long pages and long headers (e.g. https://github.com/shenef/Boktai-Speedrunning/blob/main/src/zoktai/any.md#ghouls--zombie-trap--short-sword-rng-manip). We are currently using mdBook-pagetoc and I would gladly replace it with this if it works well.

@ehuss ehuss force-pushed the dynamic-toc branch 2 times, most recently from 7ccd4d2 to 7b421eb Compare August 27, 2025 21:20
@ehuss
Copy link
Contributor Author

ehuss commented Aug 27, 2025

shows a few upcoming and previous headers relative to the current scroll point?

It shows all the headers on the page, though deeply nested headers are collapsed.

Here's a screen capture of an example:

sidebar-scroll.webm

@ehuss ehuss added this pull request to the merge queue Aug 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 27, 2025
This adds dynamic navigation of headers of the current page in the
sidebar. This is intended to help the user see what is on the current
page, and to be able to more easily navigate it. The "current" header is
tracked based on the scrolling behavior of the user, and is marked with
a small circle. This includes automatic folding to help keep it from
being too unwieldy on a page with a lot of nested headers.

This includes the `output.html.sidebar-header-nav` option to disable it.

I'm sure there are tweaks, fixes, and improvements that can be made. I'd
like to get this out now, and iterate on it over time to make
improvements.
This test is failing on CI. I don't know why, as I cannot reproduce
locally. Perhaps it is due to the update to browser-ui-test? Or perhaps
some events from the new nav bar are delaying something?
@ehuss ehuss added this pull request to the merge queue Aug 27, 2025
Merged via the queue into rust-lang:master with commit 06af133 Aug 27, 2025
14 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: waiting on a review label Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants