Skip to content

Commit b4eeb8a

Browse files
NetdocsCopilot
andcommitted
Add toc.integrate and unlink content tabs
- Implement Material's toc.integrate: when the feature is set, the page table of contents is nested under the active page inside the left navigation and the separate right-hand TOC sidebar is dropped, so a single sidebar drives navigation. Enable it on the docs-site. - Remove content.tabs.link: matching tab labels (Result/Markdown) were being synced site-wide, so switching one example's tab switched them all. Tab sets are now independent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e7751df commit b4eeb8a

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

docs-site/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"search.highlight",
3838
"search.share",
3939
"content.code.copy",
40-
"content.tabs.link",
41-
"toc.follow"
40+
"toc.follow",
41+
"toc.integrate"
4242
]
4343
},
4444

src/Netdocs.Theme.Material/templates/main.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@
4848
{{ render_nav c (path + "_" + (for.index + 1)) (level + 1) }}
4949
{{~ end ~}}
5050
</ul>
51+
{{~ if toc_integrate && node.section_index && node.section_index.url == page.url ~}}{{ render_integrated_toc }}{{~ end ~}}
5152
</nav>
5253
</li>
5354
{{~ else ~}}
5455
<li class="md-nav__item{{ if active }} md-nav__item--active{{ end }}">
5556
<a href="{{ base_url }}{{ node.url }}" class="md-nav__link{{ if active }} md-nav__link--active{{ end }}">
5657
<span class="md-ellipsis">{{ node.title }}</span>
5758
</a>
59+
{{~ if toc_integrate && node.url == page.url ~}}{{ render_integrated_toc }}{{~ end ~}}
5860
</li>
5961
{{~ end
6062
end
@@ -69,7 +71,22 @@
6971
</nav>
7072
{{~ end ~}}
7173
</li>
72-
{{~ end ~}}
74+
{{~ end
75+
func render_integrated_toc()
76+
toc_root = toc
77+
if toc && (array.size toc) > 0 && toc[0].level == 1
78+
toc_root = toc[0].children
79+
end
80+
if toc_root && (array.size toc_root) > 0 ~}}
81+
<nav class="md-nav md-nav--secondary" aria-label="Table of contents" data-md-level="0">
82+
<label class="md-nav__title" for="__toc"><span class="md-nav__icon md-icon"></span>Table of contents</label>
83+
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
84+
{{~ for entry in toc_root ~}}{{ render_toc entry }}{{~ end ~}}
85+
</ul>
86+
</nav>
87+
{{~ end
88+
end
89+
toc_integrate = features | array.contains "toc.integrate" ~}}
7390
<!doctype html>
7491
<html lang="{{ config.theme.language }}" class="no-js">
7592
<head>
@@ -143,13 +160,15 @@
143160
</div>
144161
</div>
145162
</div>
163+
{{~ if !toc_integrate ~}}
146164
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc">
147165
<div class="md-sidebar__scrollwrap">
148166
<div class="md-sidebar__inner">
149167
{{ include "partials/toc.html" }}
150168
</div>
151169
</div>
152170
</div>
171+
{{~ end ~}}
153172
<div class="md-content" data-md-component="content">
154173
<article class="md-content__inner md-typeset">
155174
{{~ if (features | array.contains "navigation.path") && breadcrumbs && (array.size breadcrumbs) > 0 ~}}

0 commit comments

Comments
 (0)