-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor readthedocs navigation template.
* Fix a nested `<li>` bug. * More closely replicate nesting of the Sphinx theme nav (related to #588). * If sections headers ever get urls, this will support them (related to #73).
- Loading branch information
Showing
3 changed files
with
35 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{%- if nav_item.url %} | ||
<a class="{% if nav_item.active%}current{%endif%}" href="{{ nav_item.url }}">{{ nav_item.title }}</a> | ||
{%- else %} | ||
<span class="caption-text">{{ nav_item.title }}</span> | ||
{%- endif %} | ||
|
||
{%- if nav_item == page or nav_item.children %} | ||
<ul class="subnav"> | ||
{%- if nav_item == page %} | ||
{% include 'toc.html' %} | ||
{%- endif %} | ||
{%- if nav_item.children %} | ||
{%- set navlevel = navlevel + 1%} | ||
{%- for nav_item in nav_item.children %} | ||
<li class="{% if navlevel > 2 %}toctree-l{{ navlevel }}{% endif %}{% if nav_item.active%} current{%endif%}"> | ||
{% include 'nav.html' %} | ||
</li> | ||
{%- endfor %} | ||
{%- set navlevel = navlevel - 1%} | ||
{%- endif %} | ||
</ul> | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,10 @@ | ||
{% if nav_item.children %} | ||
<ul class="subnav"> | ||
<li><span>{{ nav_item.title }}</span></li> | ||
|
||
{% for nav_item in nav_item.children %} | ||
{% include 'toc.html' %} | ||
{% for toc_item in page.toc %} | ||
<li class="toctree-l{{ navlevel + 1 }}"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li> | ||
{% if toc_item.children %} | ||
<ul> | ||
{% for toc_item in toc_item.children %} | ||
<li><a class="toctree-l{{ navlevel + 2 }}" href="{{ toc_item.url }}">{{ toc_item.title }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
<li class="toctree-l1 {% if nav_item.active%}current{%endif%}"> | ||
<a class="{% if nav_item.active%}current{%endif%}" href="{{ nav_item.url }}">{{ nav_item.title }}</a> | ||
{% if nav_item == page %} | ||
<ul> | ||
{% for toc_item in page.toc %} | ||
<li class="toctree-l3"><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li> | ||
{% for toc_item in toc_item.children %} | ||
<li><a class="toctree-l4" href="{{ toc_item.url }}">{{ toc_item.title }}</a></li> | ||
{% endfor %} | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
</li> | ||
{% endif %} | ||
</ul> | ||
{% endif %} | ||
{% endfor %} |