Merge pull request #26 from PR0M3TH3AN/codex/refactor-sidebar-to-use-details-summary

Refactor sidebar navigation
This commit is contained in:
thePR0M3TH3AN
2025-07-10 14:09:21 -04:00
committed by GitHub

View File

@@ -1,10 +1,21 @@
{% macro renderNav(items) %}
{% macro renderNav(items, pageUrl) %}
<ul>
{% for item in items %}
<li>
<a href="{{ item.path }}">{{ item.page.title }}</a>
{% if item.children and item.children.length %}
{{ renderNav(item.children) }}
{% set sectionPath = item.path | replace('index.html', '') %}
<details class="nav-section" {% if pageUrl.startsWith(sectionPath) %}open{% endif %}>
<summary>
<a href="{{ item.path }}" class="nav-link{% if item.path === pageUrl %} active{% endif %}">
{{ item.displayName or item.page.title }}
</a>
</summary>
{{ renderNav(item.children, pageUrl) }}
</details>
{% else %}
<a href="{{ item.path }}" class="nav-link{% if item.path === pageUrl %} active{% endif %}">
{{ item.displayName or item.page.title }}
</a>
{% endif %}
</li>
{% endfor %}
@@ -13,6 +24,6 @@
<aside class="sidebar" id="sidebar">
<nav>
{{ renderNav(navigation) }}
{{ renderNav(navigation, page.url) }}
</nav>
</aside>