aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_includes/common/navbar.html
blob: 47ebe6fea2510b85987a9f8d9065efd7eb9785aa (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<nav class="navbar navbar-default navbar-static-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="/">{{ site.settings.author.name }}</a>
    </div>
    <div class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        {% assign page_list = site.pages | where_exp: "x","x.navbar.link" | sort: "navbar.priority" %}
        {% for node in page_list %}
          {% comment %}
            Whether a page should be present in the navbar is determined by
            the presense of navbar.link in the page's front matter. It can be
            true, in which case page's title is used, or it can be custom HTML.

            If the page is paginated, it should be marked as such by setting
            navbar.paginated to true in its front matter. That way, /pageN/
            pages, which would have the same navbar_link, wouldn't appear in
            the navbar.
          {% endcomment %}
          {% if node.navbar.paginated %}
            {% if navbar_has_paginated %}
              {% continue %}
            {% endif %}
            {% assign navbar_has_paginated = true %}
          {% endif %}
          {% assign link = node.navbar.link %}
          {% if link == true %}
            {% assign link = node.title %}
          {% endif %}
          {% capture link %}{{ link | upcase }}{% endcapture %}
          {% assign icon = node.navbar.icon %}
          {% if icon %}
            {% capture icon %}<span class="glyphicon glyphicon-{{ icon }}"></span>&nbsp;{% endcapture %}
          {% endif %}
          {% if page.url == node.url %}
            <li class="active"><a href="{{ node.url | relative_url }}" class="active">{{ icon }}{{ link }}</a></li>
          {% else %}
            <li><a href="{{ node.url | relative_url }}">{{ icon }}{{ link }}</a></li>
          {% endif %}
        {% endfor %}

        {% if site.github %}
          {% assign github_link = 'GitHub' %}
          {% assign github_icon = 'globe' %}
          {% if site.settings.navbar.github %}
            {% if site.settings.navbar.github.link %}
              {% assign github_link = site.settings.navbar.github.link %}
            {% endif %}
            {% if site.settings.navbar.github.icon %}
              {% assign github_icon = site.settings.navbar.github.icon %}
            {% endif %}
          {% endif %}
          {% capture github_icon %}<span class="glyphicon glyphicon-{{ github_icon }}"></span>&nbsp;{% endcapture %}
          {% if site.settings.navbar.github == false %}
          {% else %}
            <li><a href="{{ site.github.repository_url }}" target="_blank">{{ github_icon }}{{ github_link | upcase }}</a></li>
          {% endif %}
        {% endif %}
      </ul>
    </div>
  </div>
</nav>