Files
blog/templates/partials/nav.html
daudix 7691b260a3 Fix missing labels (a11y)
Additionally add some missing translations
2024-06-20 06:48:56 +03:00

76 lines
2.3 KiB
HTML

{% set current_lang = config.default_language %}
{% if page %}
{% set current_lang = page.lang %}
{% elif section %}
{%- set current_lang = section.lang %}
{% endif %}
{% if config.extra.nav.links %}
<header id="site-nav">
<nav>
<a href="#main" id="main-content" tabindex="0">{{ trans(key="skip_to_content", lang=lang) }}</a>
<ul>
<li id="home">
<a href="{{ get_url(path="/", lang=lang) }}"
{% if current_url | default(value="/") | trim_end_matches(pat="/") | safe == get_url(path="/", lang=lang) | trim_end_matches(pat='/') | safe %}
class="active"
{% endif %}>
{{ config.title }}
</a>
</li>
{% for link in config.extra.nav.links %}
{% if current_lang == config.default_language %}
{% set title = link.name %}
{% else %}
{% set language_key = 'name_' ~ current_lang %}
{% set title = link[language_key] %}
{% endif %}
{%- if link.url is matching('https?://') %}
<li>
<a href="{{ link.url }}"
{% if current_url | default(value='/') | trim_end_matches(pat='/') | safe == link.url | trim_end_matches(pat='/') | safe %}
class="active"
{% endif %}>
{{ title }}
</a>
</li>
{%- else %}
<li>
<a href="{{ get_url(path=link.url, lang=lang)}}"
{% if current_url | default(value='/') | trim_end_matches(pat='/') | safe == get_url(path=link.url, lang=lang) | trim_end_matches(pat='/') | safe %}
class="active"
{% endif %}>
{{ title }}
</a>
</li>
{%- endif %}
{% endfor %}
{% if config.extra.nav.langs %}
<li id="dropdown">
<details>
<summary>
<i class="icon"></i>
<span class="hidden">{{ trans(key="language", lang=lang) }}</span>
</summary>
<ul>
{% for language in config.extra.nav.langs %}
<li>
<a href="{{ get_url(path="/", lang=language.code) }}">{{ language.name }}</a>
</li>
{% endfor %}
</ul>
</details>
</li>
{% endif %}
{% if config.generate_feed and config.extra.nav.show_feed %}
<li id="feed">
<a href="{{ get_url(path=config.feed_filename) }}">
<i class="icon"></i>
<span class="hidden">{{ trans(key="feed", lang=lang) }}</span>
</a>
</li>
{% endif %}
</ul>
</nav>
</header>
{% endif %}