Use relative_url filter

This commit is contained in:
Michael Rose 2018-03-20 16:16:42 -04:00
parent 4d4531d19f
commit d9bf5025f3

View file

@ -10,12 +10,12 @@
{% if nav.url %}
{% comment %} internal/external URL check {% endcomment %}
{% if nav.url contains "://" %}
{% assign domain = "" %}
{% assign nav_url = nav.url %}
{% else %}
{% assign domain = site.url | append: site.baseurl %}
{% assign nav_url = nav.url | relative_url %}
{% endif %}
<a href="{{ domain }}{{ nav.url }}"><span class="nav__sub-title">{{ nav.title }}</span></a>
<a href="{{ nav_url }}"><span class="nav__sub-title">{{ nav.title }}</span></a>
{% else %}
<span class="nav__sub-title">{{ nav.title }}</span>
{% endif %}
@ -25,9 +25,9 @@
{% for child in nav.children %}
{% comment %} internal/external URL check {% endcomment %}
{% if child.url contains "://" %}
{% assign domain = "" %}
{% assign child_url = child.url %}
{% else %}
{% assign domain = site.url | append: site.baseurl %}
{% assign child_url = child.url | relative_url %}
{% endif %}
{% comment %} set "active" class on current page {% endcomment %}
@ -37,7 +37,7 @@
{% assign active = "" %}
{% endif %}
<li><a href="{{ domain }}{{ child.url }}" class="{{ active }}">{{ child.title }}</a></li>
<li><a href="{{ child_url }}" class="{{ active }}">{{ child.title }}</a></li>
{% endfor %}
</ul>
{% endif %}