Skip to content

Commit

Permalink
Add support for article and page translations
Browse files Browse the repository at this point in the history
fixes duilio#89
  • Loading branch information
atodorov committed Jun 2, 2016
1 parent c63bf60 commit dd857bf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ pending pull requests from that repository and also merged new features from
Changelog
---------

2nd Jul 2016

- Add support for article and page translations. Fixes
`issue #89 <https://github.com/duilio/pelican-octopress-theme/issues/89>`_

21st May 2016

- Add ``DISPLAY_SOCIAL_ICONS`` setting and the ``social_icons`` sidebar
Expand Down
3 changes: 3 additions & 0 deletions templates/_includes/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ <h1 class="entry-title">{{ article.title|striptags }}</h1>
{% include '_includes/article_time.html' %}
{% include '_includes/article_stats.html' %}
{% if SHOW_DISQUS_COMMENT_COUNT and DISQUS_SITENAME %} | <a href="{{ SITEURL }}/{{ article.url }}#disqus_thread">Comments</a>{% endif %}
{% import 'translations.html' as translations with context %}
{% if article.translations %} | {% endif %}
{{ translations.translations_for(article) }}
</p>
</header>

Expand Down
4 changes: 4 additions & 0 deletions templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<header>
{% include '_includes/qr_code.html' %}
<h1 class="entry-title">{{ page.title }}</h1>
<p class="meta">
{% import 'translations.html' as translations with context %}
{{ translations.translations_for(page) }}
</p>
</header>
{{ page.content }}
</article>
Expand Down
8 changes: 8 additions & 0 deletions templates/translations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% macro translations_for(article) %}
{% if article.translations %}
Translations:
{% for translation in article.translations %}
<a href="{{ SITEURL }}/{{ translation.url }}">{{ translation.lang }}</a>{% if not loop.last %}, {% endif %}
{% endfor %}
{% endif %}
{% endmacro %}

0 comments on commit dd857bf

Please sign in to comment.