globaltoc.html 1.63 KB
Newer Older
Yuge Zhang's avatar
Yuge Zhang committed
1
2
3
4
{% 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">
Yuge Zhang's avatar
Yuge Zhang committed
5
6
7
    <li class="md-nav__item md-nav__overview">
      <a href="{{ pathto('index')|e }}" class="md-nav__link{% if pagename == 'index' %} md-nav__link--active{% endif %}">{{ _('Overview') }}</a>
    </li>
Yuge Zhang's avatar
Yuge Zhang committed
8
  {%- for item in toctree_nodes recursive %}
9
    <li class="md-nav__item{% if item.children %} md-nav__expand{% endif %}">
Yuge Zhang's avatar
Yuge Zhang committed
10
11
12
13
14
15
16
    {% 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 %}
17
18
19
20
21
22
      <a href="{{ item.href|e }}" class="md-nav__link{% if item.current %} md-nav__link--active{% endif %}">
      {% if item.children %}
        <span class="material-icons md-nav__tocarrow">&#xE5C5;</span>
      {% endif %}
      {{ item.contents }}
      </a>
Yuge Zhang's avatar
Yuge Zhang committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
      {% 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 %}