You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've built a multi-level navigation using the 11ty Navigation plugin, and was wondering if it is possible to add specific classes on each nested level respectively to achieve something like the following:
<ulclass="level-1"><li><button>Dropdown</button><ulclass="level-2"><li><!-- etc. --></li></ul></li></ul>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've built a multi-level navigation using the 11ty Navigation plugin, and was wondering if it is possible to add specific classes on each nested level respectively to achieve something like the following:
I only could figure out how to add a class on all lists that contain one or more submenus, using Nunjucks Macro Code for Rendering Unlimited Child Levels:
With this I have only one class, namely
has-submenu
, for every list element with nested submenus, regardless of its depth.To address the list element inside my navigation that has a depth level of, let's say 3, I had to write something like this:
Is there a way to specify classes on each nested level respectively?
I tried to tweak the if statement in the macro, something like
{% if entry.children.length == 1 %}
or{% if entry.children.length.1 %}
...but it doesn't work.
Beta Was this translation helpful? Give feedback.
All reactions