mystmd icon indicating copy to clipboard operation
mystmd copied to clipboard

Allow primary sidebar to only show pages from currently active section

Open mfisher87 opened this issue 6 months ago • 2 comments

The "Primary sidebar (table of contents)" currently displays a site-wide TOC. IMO that only works for a site without much depth in the content hierarchy, like a linear book where the left nav is chapter/section-based.

There are many options for building navigation, but what I'm used to personally is having the top-level nav act as the first user choice, and the sidebar showing the secondary choices. See the JupyterHub team compass for example. This is the default behavior of the pydata sphinx theme

Proposal

@choldgraf and I chatted about this and a reasonable first pass might be enabling something like a min-level and max-level - setting for the sidebar. Then, the user can build a top nav menu which represents the first level and avoid cluttering the sidebar with top level sections.

For example:

  • min-level: 0 would be everything
  • min-level: 1 would remove the home page link at the top
  • min-level: 2 would only include siblings of the current level 2 section

Eventually, I feel this navigation pattern is so common that it could be more dynamically constructed from folder structure with less information from the user. It'd be fun to think about what that might look like.

Implementation

The logic for the sidebar is somewhere around here in the myst theme repo (it's part of the react renderer logic)

Additional notes

cc @fperez, he was also interested in this :)

mfisher87 avatar May 18 '25 16:05 mfisher87