Skip to content

Commit

Permalink
support external links in navbar; fixes #3
Browse files Browse the repository at this point in the history
daattali committed Nov 19, 2015
1 parent 337a89f commit 84fbbe8
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions _includes/nav.html
Original file line number Diff line number Diff line change
@@ -13,10 +13,25 @@
<div class="collapse navbar-collapse" id="main-navbar">
<ul class="nav navbar-nav navbar-right">
{% for link in site.navbar-links %}
{% capture before %}{{ link[1] | split: "://" | first }}{% endcapture %}
{% capture after %}{{ link[1] | split: "://" | last }}{% endcapture %}
<li>
<a href="{{ site.baseurl }}/{{ link[1] }}">{{ link[0] }}</a>
</li>
{% endfor %}
{% assign internal = true %}
{% if before != after %}
{% if before == "http" or before == "https" %}
{% assign internal = false %}
{% endif %}
{% endif %}

{% if internal %}
{% capture linkurl %}{{ site.baseurl }}/{{ link[1] }}{% endcapture %}
{% else %}
{% capture linkurl %}{{ link[1] }}{% endcapture %}
{% endif %}

<a href="{{ linkurl }}">{{ link[0] }}</a>
</li>
{% endfor %}
</ul>
</div>

@@ -31,4 +46,4 @@
{% endif %}

</div>
</nav>
</nav>

0 comments on commit 84fbbe8

Please sign in to comment.