Obsoletes navbarlink with relative_url filter (#508)

This commit is contained in:
Abel Cheung 2019-06-24 05:11:26 +08:00 committed by Dean Attali
parent 8edf9a0794
commit db9bbfe546
2 changed files with 13 additions and 31 deletions

View File

@ -7,33 +7,31 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
{% if site.title-img %}
{%- if site.title-img -%}
<a class="navbar-brand navbar-brand-logo" href="{{ '' | absolute_url }}"><img src="{{ site.title-img }}"/></a>
{% else %}
{%- else -%}
<a class="navbar-brand" href="{{ '' | absolute_url }}">{{ site.title }}</a>
{% endif %}
{%- endif -%}
</div>
<div class="collapse navbar-collapse" id="main-navbar">
<ul class="nav navbar-nav navbar-right">
{% for link in site.navbar-links %}
{% if link[1].first %}
{%- for link in site.navbar-links -%}
{%- if link[1].first %}
<li class="navlinks-container">
<a class="navlinks-parent" href="javascript:void(0)">{{ link[0] }}</a>
<div class="navlinks-children">
{% for childlink in link[1] %}
{% for linkparts in childlink %}
{% include navbarlink.html link=linkparts %}
{% endfor %}
{% endfor %}
{%- for childlink in link[1] -%}
{%- for linkparts in childlink %}
<a href="{{ linkparts[1] | relative_url }}">{{ linkparts[0] }}</a>
{%- endfor -%}
{%- endfor %}
</div>
</li>
{% else %}
<li>
{% include navbarlink.html link=link %}
</li>
{% endif %}
{% endfor %}
<li><a href="{{ link[1] | relative_url }}">{{ link[0] }}</a></li>
{%- endif -%}
{%- endfor -%}
</ul>
</div>

View File

@ -1,16 +0,0 @@
{% capture before %}{{ include.link[1] | split: "://" | first }}{% endcapture %}
{% capture after %}{{ include.link[1] | split: "://" | last }}{% endcapture %}
{% assign internal = true %}
{% if before != after %}
{% if before == "http" or before == "https" %}
{% assign internal = false %}
{% endif %}
{% endif %}
{% if internal %}
{% capture linkurl %}{{ include.link[1] | relative_url }}{% endcapture %}
{% else %}
{% capture linkurl %}{{ include.link[1] }}{% endcapture %}
{% endif %}
<a href="{{ linkurl }}">{{ include.link[0] }}</a>