support external links in navbar; fixes #3

This commit is contained in:
Dean Attali 2015-11-19 01:37:41 -08:00
parent 337a89ff53
commit 84fbbe8a83

View File

@ -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>