Skip to content

Commit e7efa61

Browse files
committed
Fix empty sidebar showing on pages without matching section
Pages like /about/ and /resources/links/ had no matching sidebar section but still rendered an empty sidebar container with a full-height mobile hamburger toggle. Now uses conditional rendering with .no-sidebar class. Also adds .no-sidebar CSS rule to remove article max-width when no sidebar.
1 parent 7bfa669 commit e7efa61

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

_frontend/entrypoints/application.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107
max-width: 75ch;
108108
}
109109

110+
.documentation.no-sidebar > article {
111+
max-width: none;
112+
}
113+
110114
.documentation > article > header {
111115
margin-bottom: 2rem;
112116
padding-bottom: 1.5rem;

_layouts/toc-type.html

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
---
22
layout: default
33
---
4-
<section class="documentation">
4+
{% comment %}Determine if a sidebar section matches the current page{% endcomment %}
5+
{% assign current_section = nil %}
6+
{% for section in site.data.navigation_sidebar.sections %}
7+
{% assign _matched = false %}
8+
{% if section.match_list %}
9+
{% for m in section.match_list %}
10+
{% if page.url contains m %}{% assign _matched = true %}{% break %}{% endif %}
11+
{% endfor %}
12+
{% elsif section.match %}
13+
{% if page.url contains section.match %}{% assign _matched = true %}{% endif %}
14+
{% endif %}
15+
{% if _matched %}{% assign current_section = section %}{% break %}{% endif %}
16+
{% endfor %}
17+
{% assign _has_sidebar = true %}
18+
{% unless current_section %}{% assign _has_sidebar = false %}{% endunless %}
19+
20+
<section class="documentation{% unless _has_sidebar %} no-sidebar{% endunless %}">
21+
{% if _has_sidebar %}
522
<div class="docs-nav-backdrop"></div>
623
<button id="mobile-sidebar-toggle" class="mobile-sidebar-toggle" aria-label="Toggle section navigation">
724
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/></svg>
8-
{% assign current_section = nil %}
9-
{% for section in site.data.navigation_sidebar.sections %}
10-
{% assign _matched = false %}
11-
{% if section.match_list %}
12-
{% for m in section.match_list %}
13-
{% if page.url contains m %}{% assign _matched = true %}{% break %}{% endif %}
14-
{% endfor %}
15-
{% elsif section.match %}
16-
{% if page.url contains section.match %}{% assign _matched = true %}{% endif %}
17-
{% endif %}
18-
{% if _matched %}{% assign current_section = section %}{% break %}{% endif %}
19-
{% endfor %}
2025
{{ current_section.title }}
2126
</button>
2227
<nav class="docs-nav" aria-label="Section navigation">
2328
<div class="docs-nav-content">
2429
{% include sidebar-nav.html %}
2530
</div>
2631
</nav>
32+
{% endif %}
2733
<article>
2834
<nav class="hidden lg:flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 mb-4" aria-label="Breadcrumb" style="text-decoration:none">
2935
<ol class="flex items-center flex-wrap gap-2 list-none p-0 m-0">

0 commit comments

Comments
 (0)