aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_includes/common/navbar.html
blob: 67db12ebc8d2ed822c299fb3651748473e8176f1 (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
{% unless site.settings.navbar.hide or page.navbar.hide %}
<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>
      {% assign author_name = site.settings.author.name %}
      {% unless author_name %}
        {% if site.github %}
          {% assign author_name = site.github.owner_name %}
        {% endif %}
      {% endunless %}
      {% assign author_name = author_name | default: 'John Doe' %}
      <a class="navbar-brand" href="/">{{ 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 and site.settings.navbar.github != false %}
          {% assign github_link = site.settings.navbar.github.link | default: 'GitHub' %}
          {% assign github_icon = site.settings.navbar.github.icon | default: 'globe' %}
          {% capture github_icon %}<span class="glyphicon glyphicon-{{ github_icon }}"></span>&nbsp;{% endcapture %}
          <li><a href="{{ site.github.repository_url }}" target="_blank">{{ github_icon }}{{ github_link | upcase }}</a></li>
        {% endif %}
      </ul>
    </div>
  </div>
</nav>
{% endunless %}