-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recursive search for levels, allowing children and subs
- Loading branch information
Showing
2 changed files
with
61 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,27 @@ | ||
{% macro render_nav(navlist) %} | ||
<ul class="nav-list"> | ||
{% if page.sidebar == "core" %} | ||
{% assign navlist = site.data.navcore %} | ||
{% elsif page.sidebar == "sql" %} | ||
{% assign navlist = site.data.navsql %} | ||
{% else %} | ||
{% assign navlist = site.data.nav %} | ||
{% endif %} | ||
|
||
|
||
{% for nav in navlist %} | ||
{% if nav.subcategories != null %} | ||
{% assign current_parent = nav.subcategories | where:"page", page.path | size %} | ||
{% if current_parent != 0 %} | ||
{% assign classlist = "active" %} | ||
{% else %} | ||
{% assign classlist = "" %} | ||
{% endif %} | ||
<li class="nav-list-item {{classlist}}"> | ||
<a href="#" | ||
class="nav-list-expander"><svg viewBox="0 0 24 24"> | ||
<use xlink:href="#svg-arrow-right"></use> | ||
</svg></a> | ||
{% if nav.page %} | ||
<a class="nav-list-link" | ||
href="{% link {{ nav.page }} %}">{{ nav.title }}</a> | ||
{% else %} | ||
<a class="nav-list-link" | ||
href="#">{{ nav.title }}</a> | ||
{% endif %} | ||
<ul class="nav-list "> | ||
{% for subcategory in nav.subcategories %} | ||
{% if page.path == subcategory.page %} | ||
{% assign classlist = "active" %} | ||
{% else %} | ||
{% assign classlist = "" %} | ||
{% endif %} | ||
<li class="nav-list-item"> | ||
<a class="nav-list-link {{ classlist }}" | ||
href="{% link {{ subcategory.page }} %}">{{ subcategory.subtitle }}</a> | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</li> | ||
{% else %} | ||
{% for nav in navlist %} | ||
{% assign has_children = nav.subcategories | default: nav.children %} | ||
{% assign active_class = "" %} | ||
{% if page.path == nav.page %} | ||
{% assign classlist = "active" %} | ||
{% else %} | ||
{% assign classlist = "" %} | ||
{% assign active_class = "active" %} | ||
{% endif %} | ||
<li class="nav-list-item"> | ||
<a class="nav-list-link {{classlist}}" | ||
href="{% link {{ nav.page }} %}">{{ nav.title }}</a> | ||
|
||
<li class="nav-list-item {{ active_class }}"> | ||
{% if has_children %} | ||
<a href="#" class="nav-list-expander"> | ||
<svg viewBox="0 0 24 24"><use xlink:href="#svg-arrow-right"></use></svg> | ||
</a> | ||
{% endif %} | ||
|
||
<a class="nav-list-link" href="{% link {{ nav.page }} %}">{{ nav.title }}</a> | ||
|
||
{% if has_children %} | ||
{% render_nav has_children %} | ||
{% endif %} | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
</ul> | ||
{% endfor %} | ||
</ul> | ||
{% endmacro %} | ||
|
||
{% render_nav navlist %} |