Skip to content
10 changes: 7 additions & 3 deletions templates/components/styles/global_nav.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<nav id="global-nav" aria-label="Main">
<div class="global-nav__inner l-center">
<a class="logo-link" href="{% block homepage_link %}/{% endblock %}" hreflang="{% block homepage_hreflang %}en{% endblock %}">
{% set siteLang %} {% block homepage_hreflang %}en{% endblock %} {% endset %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the block is useful here.

Suggested change
{% set siteLang %} {% block homepage_hreflang %}en{% endblock %} {% endset %}
{% set siteLang = site.locale|default('en') %}

<a class="logo-link" href="{% block homepage_link %}/{% endblock %}" hreflang="{{ siteLang }}">
<span class="logo">
<img src="{{ absolute_url(asset('w3c/w3c-no-bars.svg', 'logos')) }}" alt="{{ 'header.logo_alt'|trans({}, 'w3c_website_templates_bundle') }}" role="img"/>
</span>
Expand All @@ -11,7 +12,9 @@
<ul data-component="nav-double-intro">
{%~ for navItem in navigation %}
<li class="top-nav-item has-children">
<a href="{{ navItem.titleLink }}" class="nav-link">{{ navItem.title }}</a>
{% set langDiff = siteLang is same as navItem.targetLinkLanguage ? false : true %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to:

Suggested change
{% set langDiff = siteLang is same as navItem.targetLinkLanguage ? false : true %}
{% set langDiff = siteLang != navItem.targetLinkLanguage %}

{% if navItem.language is defined %}{{ navItem.language }}{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some debug information

Suggested change
{% if navItem.language is defined %}{{ navItem.language }}{% endif %}

<a href="{{ navItem.titleLink }}" class="nav-link"{% if langDiff %}hreflang="{{ navItem.targetLinkLanguage }}"{% endif %}>{{ navItem.title }}</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space mising:

Suggested change
<a href="{{ navItem.titleLink }}" class="nav-link"{% if langDiff %}hreflang="{{ navItem.targetLinkLanguage }}"{% endif %}>{{ navItem.title }}</a>
<a href="{{ navItem.titleLink }}" class="nav-link"{% if langDiff %} hreflang="{{ navItem.targetLinkLanguage }}"{% endif %}>{{ navItem.title }}</a>

<div class="nav__submenu" data-nav="submenu" style="display: none;">
<div class="l-center">
<div class="nav__submenu__intro">
Expand All @@ -28,8 +31,9 @@
{% if navItem.children is defined and navItem.children|length > 0 -%}
<ul>
{%~ for child in navItem.children %}
{% set childLangDiff = siteLang is same as child.targetLinkLanguage ? false : true %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified:

Suggested change
{% set childLangDiff = siteLang is same as child.targetLinkLanguage ? false : true %}
{% set childLangDiff = siteLang != child.targetLinkLanguage %}

<li{{ child.startNewColumn is defined and child.startNewColumn ? ' class="break-after"' : '' }}>{# -#}
<a href="{{ child.url }}">{{ child.title }}</a>{# -#}
<a href="{{ child.url }}{% if childLangDiff %}hreflang="{{ child.targetLinkLanguage }}"{% endif %}">{{ child.title }}</a>{# -#}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space and wrong quoting:

Suggested change
<a href="{{ child.url }}{% if childLangDiff %}hreflang="{{ child.targetLinkLanguage }}"{% endif %}">{{ child.title }}</a>{# -#}
<a href="{{ child.url }}"{% if childLangDiff %} hreflang="{{ child.targetLinkLanguage }}"{% endif %}>{{ child.title }}</a>{# -#}

</li>
{%~ endfor %}
</ul>
Expand Down