this repo has no description
1{% macro menu() %}
2 <nav class="menu">
3 <ul class="menu__inner menu__inner--desktop">
4 {#
5 I am almost certain this check isn't necessary, that it will always
6 return true, but the only alternative I can think of is the case where
7 this config value simply doesn't exist (null)? IDK, just copying from
8 original implementation for now.
9 #}
10 {% if config.extra.show_menu_items is defined -%}
11 {% for menu_item in config.extra.main_menu | slice(end=config.extra.show_menu_items) -%}
12 {#
13 Original theme has sub-children checks on main-menu, not worrying about that here.
14 #}
15 <li>
16 <a href="{{ menu::get_link(item=menu_item) }}">{{ menu_item.name }}</a>
17 </li>
18 {% endfor -%}
19
20 {%- set main_len = config.extra.main_menu | length -%}
21 {%- set show_len = config.extra.show_menu_items -%}
22
23 {%- if main_len > show_len -%}
24 <ul class="menu__sub-inner">
25 <li class="menu__sub-inner-more-trigger">{{ config.extra.menu_more }} ▾</li>
26 <ul class="menu__sub-inner-more hidden">
27 {{ menu::items(menu=config.extra.main_menu | slice(start=config.extra.show_menu_items)) }}
28 </ul>
29 </ul>
30 {%- endif -%}
31 {# Continues the original if-check at top of file for show_menu_items #}
32 {% else -%}
33 {{ menu::items(menu=config.extra.main_menu) }}
34 {%- endif -%}
35 </ul>
36
37 <ul class="menu__inner menu__inner--mobile">
38 {{ menu::items(menu=config.extra.main_menu) }}
39 </ul>
40 </nav>
41{% endmacro menu %}
42
43{% macro items(menu) %}
44 {%- for menu_item in menu -%}
45 {# skipping sub-child check #}
46 <li>
47 <a href="{{ menu::get_link(item=menu_item) }}">{{ menu_item.name }}</a>
48 </li>
49 {%- endfor-%}
50{% endmacro items %}
51
52{% macro get_link(item) %}
53 {% if item.external is defined and item.external == true %}
54 {{ item.url }}
55 {% else %}
56 {{ get_url(path=item.url) }}
57 {% endif %}
58{% endmacro get_link %}