diff options
author | Frederick Yin <fkfd@macaw.me> | 2020-04-23 19:56:10 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@macaw.me> | 2020-04-23 19:56:10 +0800 |
commit | b8b525b213e6256513dce8ef20aa82889b4a63c2 (patch) | |
tree | 90af8a6c24329ae0396d25d0df0f2fefb21b6e52 /alabaster-lite/sidebars/navigation.html |
Initial commit
Custom alabaster theme
3 blogposts and 2 metaposts
Deployment script
Diffstat (limited to 'alabaster-lite/sidebars/navigation.html')
-rw-r--r-- | alabaster-lite/sidebars/navigation.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/alabaster-lite/sidebars/navigation.html b/alabaster-lite/sidebars/navigation.html new file mode 100644 index 0000000..3d609b0 --- /dev/null +++ b/alabaster-lite/sidebars/navigation.html @@ -0,0 +1,50 @@ +{% macro _toc_tree_inner(toc) -%} + <ul> + {% for toc_item in toc %} + <li><a href="{{ toc_item.url }}">{{ toc_item.title }}</a></li> + {{ _toc_tree_inner(toc_item.children) }} + {% endfor %} + </ul> +{%- endmacro %} + +{% macro toc_tree(toc) -%} + {# This ignores H1s #} + {% for toc_item in toc %} + {{ _toc_tree_inner(toc_item.children) }} + {% endfor %} +{%- endmacro %} + +{% macro nav_tree(nav) -%} + <ul> + {% for nav_item in nav %} + {% if not nav_item.children %} + <li> + <a href="{{ nav_item.url }}">{{ nav_item.title }}</a> + </li> + {% if nav_item == page %} + {{ toc_tree(page.toc) }} + {% endif %} + {% else %} + <li> + {{ nav_item.title }} + {{ nav_tree(nav_item.children) }} + </li> + {% endif %} + {% endfor %} + </ul> +{%- endmacro %} + +<h3>Navigation</h3> + +<nav> + {{ nav_tree(nav) }} + + {% if theme.extra_nav_links %} + <hr> + <ul> + {% for text, uri in theme.extra_nav_links.items() %} + <li class="toctree-l1"><a href="{{ uri }}">{{ text }}</a></li> + {% endfor %} + </ul> + {% endif %} +</nav> |