Merge pull request #748 from phil-opp/translations-fix

Some fixes to generated translations
This commit is contained in:
Philipp Oppermann
2020-02-17 11:32:18 +01:00
committed by GitHub
3 changed files with 25 additions and 18 deletions

View File

@@ -0,0 +1,7 @@
+++
title = "Posts"
sort_by = "weight"
insert_anchor_links = "left"
render = false
page_template = "second-edition/page.html"
+++

View File

@@ -1,22 +1,22 @@
{% macro post_link(page) %}
<div>
{% set translations = page.translations | filter(attribute="lang", value=lang) %}
{% if translations %}
{% set post = get_page(path = translations.0.path) %}
{% else %}
{% set post = page %}
{% set not_translated = true %}
{% endif %}
{% set translations = page.translations | filter(attribute="lang", value=lang) -%}
{%- if translations -%}
{%- set post = get_page(path = translations.0.path) -%}
{%- else -%}
{%- set post = page -%}
{%- set not_translated = true -%}
{%- endif -%}
<h2 class="post-title"><a href="/{{ post.path | safe }}">{{ post.title }}</a></h2>
<div class="post-summary">
{{ post.summary | safe}}
{{ post.summary | safe }}
<a class="read-more" href="/{{ post.path | safe }}"><em>read&nbsp;more&nbsp;»</em></a>
{% if lang and not_translated %}
{%- if lang and not_translated and lang != config.default_language -%}
<aside class="no-translation">
(This post is not translated yet.)
</aside>
{% endif %}
{%- endif -%}
</div>
</div>
{% endmacro post_link %}

View File

@@ -24,21 +24,21 @@
</div>
<div>
{% set chapter = "none" %}
{% for post in posts %}
{% if post.extra["chapter"] %}
{% if post.extra["chapter"] != chapter %}
{%- set chapter = "none" -%}
{%- for post in posts -%}
{%- if post.extra["chapter"] -%}
{%- if post.extra["chapter"] != chapter -%}
{# Begin new chapter #}
{% set_global chapter = post.extra["chapter"] %}
{%- set_global chapter = post.extra["chapter"] -%}
</div>
<div id="{{chapter | slugify}}" class="post-category {{chapter | slugify}}">{{ chapter }}</div>
<div class="posts {{chapter | slugify}}">
{% endif %}
{% endif %}
{%- endif -%}
{%- endif -%}
{{ macros::post_link(page=post) }}
{% endfor %}
{%- endfor -%}
</div>
<div class="posts subscribe">