59 lines
2.3 KiB
HTML
59 lines
2.3 KiB
HTML
{% macro menu() %}
|
|
<nav class="menu">
|
|
<ul class="menu__inner menu__inner--desktop">
|
|
{#
|
|
I am almost certain this check isn't necessary, that it will always
|
|
return true, but the only alternative I can think of is the case where
|
|
this config value simply doesn't exist (null)? IDK, just copying from
|
|
original implementation for now.
|
|
#}
|
|
{% if config.extra.show_menu_items is defined -%}
|
|
{% for menu_item in config.extra.main_menu | slice(end=config.extra.show_menu_items) -%}
|
|
{#
|
|
Original theme has sub-children checks on main-menu, not worrying about that here.
|
|
#}
|
|
<li>
|
|
<a href="{{ menu::get_link(item=menu_item) }}">{{ menu_item.name }}</a>
|
|
</li>
|
|
{% endfor -%}
|
|
|
|
{%- set main_len = config.extra.main_menu | length -%}
|
|
{%- set show_len = config.extra.show_menu_items -%}
|
|
|
|
{%- if main_len > show_len -%}
|
|
<ul class="menu__sub-inner">
|
|
<li class="menu__sub-inner-more-trigger">{{ config.extra.menu_more }} ▾</li>
|
|
<ul class="menu__sub-inner-more hidden">
|
|
{{ menu::items(menu=config.extra.main_menu | slice(start=config.extra.show_menu_items)) }}
|
|
</ul>
|
|
</ul>
|
|
{%- endif -%}
|
|
{# Continues the original if-check at top of file for show_menu_items #}
|
|
{% else -%}
|
|
{{ menu::items(menu=config.extra.main_menu) }}
|
|
{%- endif -%}
|
|
</ul>
|
|
|
|
<ul class="menu__inner menu__inner--mobile">
|
|
{{ menu::items(menu=config.extra.main_menu) }}
|
|
</ul>
|
|
</nav>
|
|
{% endmacro menu %}
|
|
|
|
{% macro items(menu) %}
|
|
{%- for menu_item in menu -%}
|
|
{# skipping sub-child check #}
|
|
<li>
|
|
<a href="{{ menu::get_link(item=menu_item) }}">{{ menu_item.name }}</a>
|
|
</li>
|
|
{%- endfor-%}
|
|
{% endmacro items %}
|
|
|
|
{% macro get_link(item) %}
|
|
{% if item.external is defined and item.external == true %}
|
|
{{ item.url }}
|
|
{% else %}
|
|
{{ get_url(path=item.url) }}
|
|
{% endif %}
|
|
{% endmacro get_link %}
|