Add TOC - #46
Open
lovelydinosaur wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR exposes a rendered table of contents (page.toc) in the template context and updates the built-in theme to render that TOC as a sidebar.
Changes:
- Add
tocto the page template context via a newPageContextobject. - Update the default theme template to render
{{ page.toc }}and adjust layout/CSS for a TOC sidebar. - Remove the previous “default” theme template and standalone CSS assets (now inlined in
src/mkdocs/theme/base.html).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/mkdocs/theme/base.html |
Adds TOC sidebar markup and CSS; adjusts main layout and responsive behavior. |
src/mkdocs/mkdocs.py |
Introduces PageContext with toc; passes md.toc into templates; tweaks Markdown TOC config. |
src/mkdocs/default/style.css |
Removed (styles appear to be consolidated into the theme template). |
src/mkdocs/default/highlight.css |
Removed (highlight styles appear to be consolidated into the theme template). |
src/mkdocs/default/favicon.html |
Removed (favicon is now inlined in the theme template). |
src/mkdocs/default/base.html |
Removed (replaced by src/mkdocs/theme/base.html). |
Suppressed comments (2)
src/mkdocs/theme/base.html:178
- The TOC styles are applied to the generic
navselector, which will also affect any<nav>elements coming from{{ page.html }}(markdown/shortcodes). Scope the fixed positioning rule to the TOC nav (e.g.,nav.toc) to avoid breaking user content.
nav {
position: fixed;
margin-left: 80%;
width : 20%;
padding: 2rem;
height: 100%;
overflow-y: scroll;
}
src/mkdocs/theme/base.html:186
- Similarly, the TOC list/link styles use generic
nav ul/li/aselectors, which can restyle any<nav>in page content. Scope these selectors to the TOC nav so only the generated TOC is affected.
nav ul {
padding: 0;
margin: 0;
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Make
page.tocavailable for templating, and include in the default theme.