globaltoc.html 1.25 KB
Newer Older
Yuge Zhang's avatar
Yuge Zhang committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{% set toctree = toctree(maxdepth=theme_globaltoc_depth|toint, collapse=theme_globaltoc_collapse|tobool, includehidden=theme_globaltoc_includehidden|tobool, titles_only=True) %}
{% if toctree and sidebars and 'globaltoc.html' in sidebars %}
  {% set toctree_nodes = derender_toc(toctree, False) %}
  <ul class="md-nav__list">
  {%- for item in toctree_nodes recursive %}
    <li class="md-nav__item">
    {% if "caption" in item %}
      <span class="md-nav__link caption">{{ item.caption }}</span>
    {% else %}
    {% if item.current %}
    <input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">
    <label class="md-nav__link md-nav__link--active" for="__toc"> {{ item.contents }} </label>
    {% endif %}
      <a href="{{ item.href|e }}" class="md-nav__link{% if item.current %} md-nav__link--active{% endif %}">{{ item.contents }}</a>
      {% if item.current %}
        {%- set sphinx_material_include_searchbox=False %}
        {% include "localtoc.html" %}
      {% endif %}
      {%- set sphinx_material_include_searchbox=True %}
      {%- if item.children -%}
        <ul class="md-nav__list"> {{ loop(item.children) }}</ul>
      {%- endif %}
    {% endif %}
    </li>
  {%- endfor %}
  </ul>
  {# TODO: Fallback to toc? #}
{% endif %}