Skip to content

Commit eab56c7

Browse files
committed
Show localizations links if available on blog page
1 parent c647789 commit eab56c7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

_layouts/post.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,25 @@
33
---
44
<link rel="stylesheet" href="/assets/css/main.css">
55

6+
{% assign baseurl = page.permalink | remove_first: "/" | remove_first: page.lang %}
7+
8+
{% for lang in site.languages %}
9+
{% assign localization = "/" | append: lang | append:baseurl %}
10+
{% assign locale = site.posts | where:"permalink", localization %}
11+
{% assign localizations = localizations | concat: locale %}
12+
{% endfor %}
13+
614
<article class="post">
715

816
<header class="post-header">
17+
{% if localizations.size > 0 %}
18+
<div class="localization">
19+
<a href="{{ '/en' | append:baseurl }}">en</a>
20+
{% for locale in localizations %}
21+
| <a href="{{ locale.url }}">{{locale.lang}}</a>
22+
{% endfor %}
23+
</div>
24+
{% endif %}
925
<h1 class="post-title">{{ page.title | escape }}</h1>
1026
<p class="post-meta">
1127
<time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}">

0 commit comments

Comments
 (0)