Files
blog_os/blog/templates/edition-2/macros.html
2021-01-04 17:50:02 +03:30

45 lines
1.7 KiB
HTML

{% macro latest_post(posts) %}
{% set post = posts|last %}
<strong><a href="{{ post.path | safe }}">{{ post.title }}</a></strong>
{% endmacro latest_post %}
{% macro post_link(page) %}
{% 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 -%}
<div{% if post.extra.rtl %} class="right-to-left"{% endif %}>
<h2 class="post-title"><a href="{{ post.path | safe }}">{{ post.title }}</a></h2>
<div class="post-summary">
{{ post.summary | safe }}
<a class="read-more" href="{{ post.path | safe }}"><em>{{ trans(key="readmore", lang=lang) | safe }}</em></a>
{%- if lang and not_translated and lang != config.default_language -%}
<aside class="no-translation">
{{ trans(key="not_translated", lang=lang) }}
</aside>
{%- endif -%}
</div>
</div>
{% endmacro post_link %}
{% macro toc(toc) %}
<details id = "toc-inline">
<summary><b>{{ trans(key="toc", lang=lang) }}</b></summary>
<ul>
{% for h2 in toc %}<li>
<a href="#{{h2.id | safe}}">{{ h2.title | safe }}</a>
{% if h2.children %}<ul>
{% for h3 in h2.children %}<li>
<a href="#{{h3.id | safe}}">{{ h3.title | safe }}</a>
</li>{% endfor %}
</ul>{% endif %}
</li>{% endfor %}
<li class="toc-comments-link"><a href="#comments">{{ trans(key="comments", lang=lang) }}</a></li>
</ul>
</details>
{% endmacro toc %}