Skip to content

Commit da5e938

Browse files
committed
refactor navbar menus code
1 parent 45d36f0 commit da5e938

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

_includes/nav.html

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,14 @@
1919
<div class="navlinks-children">
2020
{% for childlink in link[1] %}
2121
{% for linkparts in childlink %}
22-
{% capture before %}{{ linkparts[1] | split: "://" | first }}{% endcapture %}
23-
{% capture after %}{{ linkparts[1] | split: "://" | last }}{% endcapture %}
24-
{% assign internal = true %}
25-
{% if before != after %}
26-
{% if before == "http" or before == "https" %}
27-
{% assign internal = false %}
28-
{% endif %}
29-
{% endif %}
30-
31-
{% if internal %}
32-
{% capture linkurl %}{{ site.baseurl }}/{{ linkparts[1] }}{% endcapture %}
33-
{% else %}
34-
{% capture linkurl %}{{ linkparts[1] }}{% endcapture %}
35-
{% endif %}
36-
37-
<a href="{{ linkurl }}">{{ linkparts[0] }}</a>
22+
{% include navbarlink.html link=linkparts %}
3823
{% endfor %}
3924
{% endfor %}
4025
</div>
4126
</li>
4227
{% else %}
4328
<li>
44-
{% capture before %}{{ link[1] | split: "://" | first }}{% endcapture %}
45-
{% capture after %}{{ link[1] | split: "://" | last }}{% endcapture %}
46-
{% assign internal = true %}
47-
{% if before != after %}
48-
{% if before == "http" or before == "https" %}
49-
{% assign internal = false %}
50-
{% endif %}
51-
{% endif %}
52-
53-
{% if internal %}
54-
{% capture linkurl %}{{ site.baseurl }}/{{ link[1] }}{% endcapture %}
55-
{% else %}
56-
{% capture linkurl %}{{ link[1] }}{% endcapture %}
57-
{% endif %}
58-
59-
<a href="{{ linkurl }}">{{ link[0] }}</a>
29+
{% include navbarlink.html link=link %}
6030
</li>
6131
{% endif %}
6232
{% endfor %}

0 commit comments

Comments
 (0)