rf-web/_includes/common/lang-selector.html
2020-08-17 22:11:19 +02:00

38 lines
1.4 KiB
HTML

{% assign posts=site.posts | where:"ref", page.ref | sort: 'lang' %}
{% assign pages=site.pages | where:"ref", page.ref | sort: 'lang' %}
<div class="nav-group lang-selector">
{% if posts.size > 1 %}
{% for post in posts %}
{% if post.lang != page.lang %}
<a href="{{ site.base-url }}{{ post.url }}" class="lang lang--{{ page.lang }}">
{% if page.lang == 'en' %}
{{ include.fr-text }}
{% else %}
{{ include.en-text }}
{% endif %}
</a>
{% endif %}
{% endfor %}
{% elsif pages.size > 1 %}
{% for newpage in pages %}
{% if newpage.lang != page.lang and page.ref != '' %}
{% if page.lang == 'en' %}
<a href="{{ newpage.url }}" class="lang lang--{{ page.lang }}">{{ include.fr-text }}</a>
{% else %}
<a href="{{ newpage.url }}" class="lang lang--{{ page.lang }}">{{ include.en-text }} </a>
{% endif %}
{% endif %}
{% endfor %}
{% elsif page.lang == 'en' %}
<a href="{{ site.baseurl }}/fr" class="lang lang--{{ page.lang }}">{{ include.fr-text }}</a>
{% else %}
<a href="{{ site.baseurl }}/" class="lang lang--{{ page.lang }}">{{ include.en-text }} </a>
{% endif %}
</div>