Skip to content

Commit a6624ca

Browse files
committed
add navigation html template for docs
1 parent 9223ef3 commit a6624ca

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/_include/navigation.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!-- This finds the current page so it can be highlighted. -->
2+
3+
{% for entry in site.data.navigation %}
4+
{% capture fullurl %}{{ site.baseurl }}{{ entry.url }}{% endcapture %}
5+
{% if fullurl == page.url %}
6+
{% assign current_page = fullurl %}
7+
{% break %}
8+
{% elsif page.url contains fullurl %}
9+
{% assign current_page = fullurl %}
10+
{% endif %}
11+
{% endfor %}
12+
13+
<!-- Then we build the nav bar. -->
14+
<nav>
15+
<ul>
16+
{% for entry in site.data.navigation %}
17+
{% if entry.url == current_page %}
18+
{% assign current = ' class="current"' %}
19+
{% else %}
20+
<!-- We have to declare it 'null' to ensure it doesn't propagate. -->
21+
{% assign current = null %}
22+
{% endif %}
23+
{% assign sublinks = entry.sublinks %}
24+
{% if sublinks %}
25+
<li{{ current }}>
26+
<a href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a>
27+
<ul>
28+
{% for sublink in sublinks %}
29+
<li><a href="{{ site.baseurl }}{{ sublink.url }}">{{ sublink.title }}</a></li>
30+
{% endfor %}
31+
</ul>
32+
</li>
33+
{% else %}
34+
<li{{ current }}><a href="{{ site.baseurl }}{{ entry.url }}">{{ entry.title }}</a></li>
35+
{% endif %}
36+
{% endfor %}
37+
</ul>
38+
</nav>

0 commit comments

Comments
 (0)