~xdavidwu/xdavidwu.link

ref: b721023f72acc0f8db9bd2c74d7a2e0fb7fb0d1e xdavidwu.link/_includes/nav_list -rw-r--r-- 1.5 KiB
b721023f — Michael Rose Fix typo and update link to beta release post 8 years ago
                                                                                
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
{% include base_path %}
{% assign navigation = site.data.navigation[include.nav] %}

<nav class="nav__list">
  {% if page.sidebar.title %}<header><h4 class="nav__title" style="padding: 0;">{{ page.sidebar.title }}</h4></header>{% endif %}
  <ul>
    {% for nav in navigation %}
      <li>
        {% if nav.url %}
          {% comment %}internal/external URL check{% endcomment %}
          {% if nav.url contains "://" %}
            {% assign domain = "" %}
          {% else %}
            {% assign domain = base_path %}
          {% endif %}

          <a href="{{ domain }}{{ nav.url }}"><span class="nav__sub-title">{{ nav.title }}</span></a>
        {% else %}
          <span class="nav__sub-title">{{ nav.title }}</span>
        {% endif %}

        {% if nav.children != null %}
        <ul>
          {% for child in nav.children %}
            {% comment %}internal/external URL check{% endcomment %}
            {% if child.url contains "://" %}
              {% assign domain = "" %}
            {% else %}
              {% assign domain = base_path %}
            {% endif %}

            {% comment %}set "active" class on current page{% endcomment %}
            {% if child.url == page.url %}
              {% assign active = "active" %}
            {% else %}
              {% assign active = "" %}
            {% endif %}

            <li><a href="{{ domain }}{{ child.url }}" class="{{ active }}">{{ child.title }}</a></li>
          {% endfor %}
        </ul>
        {% endif %}
      </li>
    {% endfor %}
  </ul>
</nav>