aboutsummaryrefslogtreecommitdiff
path: root/templates/_macros.html
blob: 63d6c9809371d55213894df9504e5f4a38f01c2e (plain) (blame)
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
{% macro render_header() %}
{% set root_section = get_section(path="_index.md") %}
{% set active_section = "" %}
{% if page and page.components  %}
    {% set active_section = page.components[0] %}
{% elif section and section.components %}
    {% set active_section = section.components[0] %}
{% endif %}

<a href="{{ root_section.permalink }}">
    <div class="logo">
        <img src="{{ get_url(path=config.extra.juice_logo_path) }}" alt="logo">
        {{ config.extra.juice_logo_name }}
    </div>
</a>
<nav>
    <ul>
        {% for subpath in root_section.subsections %}
            {% set sub = get_section(path=subpath) %}
            {% set is_active = sub.components[0] == active_section %}
            {% if not 'hide_from_menu' in sub.extra or not sub.extra.hide_from_menu %}
                <li>
                    <a class="nav-item text{% if is_active %} active{% endif %}" href="{{ sub.permalink }}">{{ sub.title }}</a>
                </li>
            {% endif %}
        {% endfor %}
        {% if config.extra.juice_extra_menu %}
            {% for menu in config.extra.juice_extra_menu %}
                <li><a class="nav-item text" href="{{ menu.link }}">{{ menu.title }}</a></li>
            {% endfor %}
        {% endif %}
    </ul>
</nav>
{% endmacro render_header %}