Skip to content

Commit

Permalink
mkdocs-material: fix displaying arrow for sections with 1 child page
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
oprypin committed Mar 30, 2022
1 parent fa0de5c commit 4ad5a24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mkdocs_section_index/rewrites.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def _transform_material_nav_item_template(src: str) -> str:
return src.replace(
"{% set indexes = [] %}",
"{% set indexes = [nav_item] if nav_item.url else [] %}",
).replace(
"{% if nav_item.children | length > 1 %}",
"{% if nav_item.children %}",
)

# The above only for versions >= 7.3, the below only for versions < 7.3.
Expand Down
2 changes: 1 addition & 1 deletion tests/rewrites/material-nav-item-4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ output: |
{% set class = "md-nav__link--active" if index == page %}
<div class="md-nav__link md-nav__link--index {{ class }}">
<a href="{{ index.url | url }}">{{ nav_item.title }}</a>
{% if nav_item.children | length > 1 %}
{% if nav_item.children %}
<label for="{{ path }}">
<span class="md-nav__icon md-icon"></span>
</label>
Expand Down

0 comments on commit 4ad5a24

Please sign in to comment.