Skip to content

Commit

Permalink
Conditionally show navigation items
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Jul 9, 2024
1 parent 9388cc2 commit 7b76550
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x-govuk/components/primary-navigation/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h2 class="govuk-visually-hidden" id="primary-navigation-heading">{{ params.visuallyHiddenTitle or "Menu" }}</h2>
<ul class="x-govuk-primary-navigation__list">
{%- for item in params.items %}
{% if item.href %}
{% if item %}
<li class="x-govuk-primary-navigation__item {{ "x-govuk-primary-navigation__item--current" if item.current }}{% if item.classes %} {{ item.classes }}{% endif -%}">
<a class="x-govuk-primary-navigation__link" {{ "aria-current=page" if item.current }} href="{{ item.href }}">
{{- item.text -}}
Expand Down
2 changes: 2 additions & 0 deletions x-govuk/components/secondary-navigation/template.njk
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<nav class="x-govuk-secondary-navigation {%- if params.classes %} {{ params.classes }}{% endif -%}" {% if params.labelledBy %}aria-labelledby="{{ params.labelledBy }}"{% else %}aria-label="{{ params.visuallyHiddenTitle or "Secondary menu" }}"{% endif %} {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
<ul class="x-govuk-secondary-navigation__list">
{% for item in params.items %}
{% if item %}
<li class="x-govuk-secondary-navigation__list-item {{ "x-govuk-secondary-navigation__list-item--current" if item.current }}{% if item.classes %} {{ item.classes }}{% endif -%}">
<a class="x-govuk-secondary-navigation__link" href="{{ item.href }}" {{ "aria-current=page" if item.current }}>
{{ item.text }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
</nav>
2 changes: 2 additions & 0 deletions x-govuk/components/sub-navigation/template.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{% endif %}
<ul class="x-govuk-sub-navigation__section">
{% for item in items %}
{% if item %}
<li class="x-govuk-sub-navigation__section-item{% if item.parent or item.current %} x-govuk-sub-navigation__section-item--current{% endif %}">
<a class="x-govuk-sub-navigation__link" href="{{ item.href }}"{% if item.current %} aria-current="true"{% endif %}>{{ item.text }}</a>
{% if item.parent and item.children | length > 0 %}
Expand All @@ -19,6 +20,7 @@
</ul>
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
Expand Down

0 comments on commit 7b76550

Please sign in to comment.