Skip to content
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

Auto-anchor the sidebar to the openned page #4345

Open
4 tasks done
Veetaha opened this issue Nov 7, 2024 · 0 comments
Open
4 tasks done

Auto-anchor the sidebar to the openned page #4345

Veetaha opened this issue Nov 7, 2024 · 0 comments

Comments

@Veetaha
Copy link

Veetaha commented Nov 7, 2024

Is your feature request related to a problem? Please describe.

Suppose I share you a link to vitepress documentation like this: https://vitepress.dev/guide/sitemap-generation.

When you open this link, the view you see is this:
image

Notice that the sidebar is always scrolled to the top. You don't see the currently active page in the sidebar, so you have to scroll down a bit to find it. This is inconvenient, when there is a long sidebar with several sections and you want to discover other pages adjacent to this one within the same section.

Describe the solution you'd like

I think when you open the page, the sidebar should automatically scroll to the active page.

It's possible there could be multiple links to the same page in the sidebar, in which case I think anchoring to the first of them is fine.

Another interesting feature is highlighting the anchored item. This applies both to sidebar and to regular anchors to heareds on the page. See an example how it works in rustdoc. If you click the following link, it'll anchor you to a specific header, and it'll also highlight that header with a short blink: https://doc.rust-lang.org/stable/std/#what-is-in-the-standard-library-documentation, and keeps a persistent dimmed highlighting background color on the header.

Maybe something like this could also be implemented in Vitepress for anchors to headers and in the sidebar.

Validations

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

No branches or pull requests

1 participant