diff --git a/mkdocs_section_index/rewrites.py b/mkdocs_section_index/rewrites.py index 24b0514..848f7f2 100644 --- a/mkdocs_section_index/rewrites.py +++ b/mkdocs_section_index/rewrites.py @@ -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. diff --git a/tests/rewrites/material-nav-item-4.yml b/tests/rewrites/material-nav-item-4.yml index 2e52f8f..2c7ffd4 100644 --- a/tests/rewrites/material-nav-item-4.yml +++ b/tests/rewrites/material-nav-item-4.yml @@ -131,7 +131,7 @@ output: | {% set class = "md-nav__link--active" if index == page %}