Skip to content

Commit 6d744da

Browse files
committed
Adjust tree-root link for "self" roots: link to parent page
1 parent fd07609 commit 6d744da

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

docsy.dev/content/en/docs/adding-content/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
title: Content and Customization
33
weight: 3
44
description: How to add content to and customize your Docsy site.
5-
sidebar_root_for: children
5+
sidebar_root_for: self
66
---

docsy.dev/content/en/docs/best-practices/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: "Best Practices"
33
weight: 9
44
description: >
55
Optional guidance and recommendations about organizing, authoring, and managing your technical documentation.
6+
sidebar_root_for: children
67
---
78

89
Use this section to learn about some of the best practices around creating technical documentation with Docsy.

layouts/_partials/sidebar-tree.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
$s.Params.manualLinkTitle
111111
$s.Title
112112
-}}
113+
{{ if and $treeRoot (eq $s.Params.sidebar_root_for "self") -}}
114+
{{ with $s.Parent -}}
115+
{{ $manualLink = .RelPermalink -}}
116+
{{ end -}}
117+
{{ end -}}
113118
<li class="td-sidebar-nav__section-title td-sidebar-nav__section
114119
{{- if $withChild }} with-child{{ else }} without-child{{ end -}}
115120
{{ if $activePath }} active-path{{ end -}}

tasks/sidebar-root-feature.plan.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ interaction handling is required.
4343

4444
**Support both `children` and `self` values:**
4545

46-
- If current page is a section with `sidebar_root_for: "self"`, use it as sidebar root
46+
- If current page is a section with `sidebar_root_for: "self"`, use it as
47+
sidebar root
4748
- Otherwise, walk up ancestors to find any section with `sidebar_root_for`
4849
(either `"self"` or `"children"`)
4950
- Use the closest match as sidebar root
@@ -52,6 +53,7 @@ interaction handling is required.
5253
- Pass `sidebarRoot` to `sidebar-tree.html` as parameter
5354

5455
**Logic:**
56+
5557
1. Check if current page has `sidebar_root_for: "self"` → use it
5658
2. Else check ancestors for `sidebar_root_for` (any value) → use first match
5759
3. Result: `self` applies to section itself, `children` only to descendants
@@ -113,18 +115,21 @@ sidebar_root_for: children
113115
```
114116

115117
**With `sidebar_root_for: children`:**
118+
116119
- Viewing `/docs/adding-content/` index → shows **full** docs navigation
117120
- Viewing `/docs/adding-content/content/` → shows **rooted** sidebar (only
118121
"Content and Customization" and its children)
119122

120123
**With `sidebar_root_for: self`:**
124+
121125
- Viewing `/docs/adding-content/` index → shows **rooted** sidebar
122126
- Viewing `/docs/adding-content/content/` → shows **rooted** sidebar
123127
- Both the section itself and descendants get the focused navigation
124128

125129
### To-dos
126130

127-
- [ ] Step 1: Update sidebar_root_for lookup to support both "self" and "children" values
131+
- [ ] Step 1: Update sidebar_root_for lookup to support both "self" and
132+
"children" values
128133
- [ ] Step 2: Add link back to site root section index page
129134
- [ ] Step 3: Add breadcrumb navigation UI (OPTIONAL/FUTURE)
130135
- [x] Step 4: Use sidebar_root_for for $navRoot calculation in sidebar-tree.html

0 commit comments

Comments
 (0)