I've tried a couple of things, and I'm not sure what I've got so far is the best way to do this. I have a series of 5 categories, which correspond to a set of 5 top-level directories. These 5 categories make up the top level navigation.
Within these 5 directories are all of the pages that should be listed in the sub-nav when one of the categories is selected. So the structure is:
--- html
├── pages
├── 01.category
├── 01.page
└── docs.md
├── 02.page
└── docs.md
└── category.md
├── 02.category
├── 01.page
└── docs.md
├── 02.page
└── docs.md
└── category.md
I'm using the sidebar code from the rtfm theme, and on the top-level it works great:
{% macro loop(page, parent_loop) %}
{% if parent_loop|length > 0 %}
{% set data_level = parent_loop %}
{% else %}
{% set data_level = 0 %}
{% endif %}
{% for p in page.children.visible %}
{% set parent_page = p.activeChild ? ' parent' : '' %}
{% set current_page = p.active ? ' active' : '' %}
<li class="dd-item{{ parent_page }},{{ current_page }}" data-nav-id="{{ p.route }}">
{% if p.children.count > 0 %}
<span class="group-name">{{ p.menu }}</span>
<ul>
{{ _self.loop(p, parent_loop+loop.index) }}
</ul>
{% else %}
<a href="{{ p.url }}"><span>{{ p.menu }}</span></a>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% macro version(p) %}
{% set parent_page = p.activeChild ? ' parent' : '' %}
{% set current_page = p.active ? ' active' : '' %}
<h5 class="{{ parent_page }},{{ current_page }}">
{% if p.activeChild or p.active %}
<i class="fa fa-chevron-down fa-fw"></i>
{% else %}
<i class="fa fa-plus fa-fw"></i>
{% endif %}
<a href="{{ p.url }}">{{ p.menu }}</a>
</h5>
{% endmacro %}
{% if theme_config.top_level_version %}
{% for slug, ver in pages.children %}
{{ _self.version(ver) }}
<ul id="{{ slug }}" class="topics">
{{ _self.loop(ver, '') }}
</ul>
{% endfor %}
{% else %}
<ul class="topics">
{{ _self.loop(pages, '') }}
</ul>
{% endif %}
once you click on any of the pages the parent_loop gets refreshed, and the menu changes. I'd like it to be more or less static once it's built after selecting one of the categories. And right now, I'm drawing a blank.
Here's a screenshot as well. [Top-level-category](//muut.com/u/getgrav/s2/:getgrav:4TN3:toplevelcategory.jpg.jpg)