Closed zecakeh closed 2 weeks ago
Writing it here for want of somewhere better: I wondered if we could avoid cloning the whole of sidebar-tree.html
by putting toc.html
back in baseof.html
. The answer is that we can, with some custom CSS, along the lines of:
baseof.html:
- {{ partial "sidebar.html" . }}
+ <div class="sidebar-div td-sidebar-nav">
+ {{ partial "sidebar.html" . }}
+ {{ partial "toc.html" . }}
+ </div>
Custom CSS:
.sidebar-div {
overflow-y: auto;
position: sticky;
top: 4rem;
height: calc(100vh - 5rem);
}
.td-sidebar__inner {
height: auto !important;
position: static !important;
}
(In other words, we have to move the height
and position
from .td-sidebar__inner
to a higher-level div.) But frankly, that looks more brittle than just forking sidebar-tree.html
.
Thanks to the
.RenderShortcodes
function added in Hugo 0.117.0, we can include the CS modules and all the headings are included in the generated ToC, with unique IDs. This avoids to do it with JavaScript in the browser.This should fix the issue in #1841.
This might however leave some duplicate IDs in the code generated from OpenAPI definitions.
Pull Request Checklist
Preview: https://pr1851--matrix-spec-previews.netlify.app