{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}

<header id="site-nav">
	<nav>
		<a href="#main-content" tabindex="0">
			{{ macros_translate::translate(key="skip_to_content", default="Skip to Main Content", language_strings=language_strings) }}
		</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>
			<li></li>
			{%- for link in config.extra.nav.links %}
				{%- if link.menu and link.menu | length > 0 -%}
					<li>
						<details class="closable">
							<summary>{{- macros_translate::translate(key=link.name, default=link.name, language_strings=language_strings) -}}</summary>
							<ul>
								{%- for link in link.menu -%}
									{%- if link.url is matching('https?://') %}
										<li>
											<a href="{{ link.url }}" rel="{{ rel_attributes }}" class="external">
												{{- macros_translate::translate(key=link.name, default=link.name, language_strings=language_strings) -}}
											</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 -%}>
												{{- macros_translate::translate(key=link.name, default=link.name, language_strings=language_strings) -}}
											</a>
										</li>
									{%- endif %}
								{%- endfor -%}
							</ul>
						</details>
			 		 </li>
				{%- elif link.url is matching('https?://') %}
					<li>
						<a href="{{ link.url }}" rel="{{ rel_attributes }}" class="external">
							{{- macros_translate::translate(key=link.name, default=link.name, language_strings=language_strings) -}}
						</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 -%}>
							{{- macros_translate::translate(key=link.name, default=link.name, language_strings=language_strings) -}}
						</a>
					</li>
				{%- endif %}
			{%- endfor -%}
			{%- if config.languages | length > 0 %}
				{%- include "partials/language_switcher.html" %}
			{%- endif -%}
			{%- if config.extra.source_url and config.extra.nav.show_repo %}
				<li id="repo">
					<a class="circle" href="{{ config.extra.source_url }}" title="{{ macros_translate::translate(key='repo', default='Repository', language_strings=language_strings) }}">
						<i class="icon"></i>
					</a>
				</li>
			{%- endif %}
		</ul>
	</nav>
</header>
