1
0
em.0x45.cz/templates/macros.html

43 lines
1.1 KiB
HTML
Raw Normal View History

2021-12-04 18:20:01 +01:00
{% macro list_posts(section, count=0) %}
2021-12-02 11:53:48 +01:00
{% set section = get_section(path=section~"/_index.md") %}
{% for page in section.pages %}
2021-12-04 18:20:01 +01:00
{% if loop.index > count and count != 0 %}
2021-12-02 11:53:48 +01:00
{% break %}
{% endif %}
{{ macros::print_article(page=page) }}
{% endfor %}
{% endmacro %}
{% macro print_article(page) %}
<article>
<h1><a href="{{ page.permalink }}">{{ page.title }}</a></h1>
<p>{{ page.summary | safe }}</p>
2021-12-02 12:08:48 +01:00
{{ self::page_info(page=page) }}
2021-12-02 11:53:48 +01:00
</article>
{% endmacro %}
2021-12-02 12:08:48 +01:00
{% macro page_info(page) %}
{% if page.date %}
<div class="info">
<span class="date">{{ page.date }}</span>
{%- if page.extra.author -%}
, <span class="author">{{ page.extra.author }}</span>
{% endif %}
2021-12-04 18:05:15 +01:00
{% if page.taxonomies.categories %}
<div class="taxonomy">
{{ self::list_taxonomy(kind="categories", prepend="#") }}
</div>
{% endif %}
</div>
{% endif %}
2021-12-02 12:08:48 +01:00
{% endmacro %}
2021-12-04 18:05:15 +01:00
{% macro list_taxonomy(kind, prepend="") %}
<ul>
{% set taxonomy = get_taxonomy(kind=kind) %}
{% for term in taxonomy.items %}
2021-12-04 18:05:15 +01:00
<li class="item"><a href="{{ term.permalink | safe }}">{{prepend}}{{ term.name }}</a></li>
{% endfor %}
</ul>
{% endmacro list_categories %}