-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsidebar-menu.twig
56 lines (47 loc) · 1.63 KB
/
sidebar-menu.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<aside id="docs-menu" class="box is-shadowless is-radiusless has-background-light pt-6 pb-6">
<a href="{{ "index"|link }}" class="icon-text is-hidden-desktop pb-3">
<h1 class="title is-6">{{site_title}}</h1>
</a>
{% set root = pages["index"].tree_node %}
{{ _self.menu_level(root, current_page, 0) }}
</aside>
{# recursive sub menu #}
{% macro menu_level(root_node, current_page, level) %}
<ul class="tree{% if level == 0 %} trunk{% endif %}">
{% for node in root_node.children if not node.page.hidden and not node.page.meta.menuhidden %}
<li
class="node{% if node.page.id == current_page.id %} is-active{% endif %}">
{# Folder #}
{% if node.children %}
<input type="checkbox" id="trigger-{{node.id|split('/')|last|url_encode}}" {% if node.id in current_page.id %} checked {% endif %}>
<label for="trigger-{{node.id|split('/')|last|url_encode}}" class="icon-text">
<span class="icon">
<i class="fa fa-folder fa-fw has-text-info"></i>
</span><span>
{% if node.page.title %}
{{node.page.title}}
{% else %}
{{node.id|split('/')|last}}
{% endif %}
</span>
</label>
{# Recursion one level deeper #}
{{ _self.menu_level(node, current_page, level+1) }}
{# Page #}
{% else %}
<a href="{{ node.page.url }}" class="icon-text">
<span class="icon">
<i class="fa fa-file fa-fw has-text-white"></i>
</span><span>
{% if node.page.title %}
{{node.page.title}}
{% else %}
{{node.id|split('/')|last}}
{% endif %}
</span>
</a>
{% endif %}
</li>
{% endfor %}
</li>
</ul>{% endmacro %}