From d6c819c26587e03ba4124a9c2b6056464d163e03 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 6 May 2026 13:57:46 +0800 Subject: [PATCH] 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. --- _frontend/entrypoints/application.css | 4 ++++ _layouts/toc-type.html | 32 ++++++++++++++++----------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/_frontend/entrypoints/application.css b/_frontend/entrypoints/application.css index 53c8ed7..66b07cf 100644 --- a/_frontend/entrypoints/application.css +++ b/_frontend/entrypoints/application.css @@ -107,6 +107,10 @@ max-width: 75ch; } +.documentation.no-sidebar > article { + max-width: none; +} + .documentation > article > header { margin-bottom: 2rem; padding-bottom: 1.5rem; diff --git a/_layouts/toc-type.html b/_layouts/toc-type.html index 3f061c2..fa724fc 100644 --- a/_layouts/toc-type.html +++ b/_layouts/toc-type.html @@ -1,22 +1,27 @@ --- layout: default --- -
+{% comment %}Determine if a sidebar section matches the current page{% endcomment %} +{% assign current_section = nil %} +{% for section in site.data.navigation_sidebar.sections %} + {% assign _matched = false %} + {% if section.match_list %} + {% for m in section.match_list %} + {% if page.url contains m %}{% assign _matched = true %}{% break %}{% endif %} + {% endfor %} + {% elsif section.match %} + {% if page.url contains section.match %}{% assign _matched = true %}{% endif %} + {% endif %} + {% if _matched %}{% assign current_section = section %}{% break %}{% endif %} +{% endfor %} +{% assign _has_sidebar = true %} +{% unless current_section %}{% assign _has_sidebar = false %}{% endunless %} + +
+ {% if _has_sidebar %}
+ {% endif %}