blog.notmyidea.org/theme/templates/macros/list_articles.html
2019-11-20 13:56:44 +01:00

30 lines
No EOL
1.6 KiB
HTML

{% macro list_articles(articles, included_categories, excluded_categories=(), title=None, display_category=True, limit=None, see_more=None) -%}
<ul class="articles_list">
{% if title is defined %}<li><span class="metadata date"><h2>{{ title }}</h2></span></li>{% endif %}
{% for article in articles | rejectattr("category", "in", excluded_categories) | selectattr("category", "in", included_categories) | batch(limit) | first %}
{% if not article.unlisted or article.category == category %}
<li>
<span class="metadata date">{{ article.date.strftime("%B %Y") }}</span>
<a class="post_title" href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a>&nbsp;
{% if display_category %}<span class="metadata category">{{ article.category }}</span>{% endif %}
</li>
{% endif %}
{% endfor %}
{% if see_more %}<li><span class="metadata date"></span><a class="post_title" href="{{ see_more }}">plus d'articles </a>&nbsp;</li>{% endif %}
</ul>
{%- endmacro %}
{% macro list_tag(articles, title, limit=None) -%}
<ul class="articles_list">
{% if title is defined %}<li><span class="metadata date"><h2>{{ title }}</h2></span></li>{% endif %}
{% for article in articles | batch(limit) | first %}
<li>
<span class="metadata date">{{ article.date.strftime("%B %Y") }}</span>
<a class="post_title" href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a>&nbsp;
<span class="metadata category">{{ article.category }}</span>
</li>
{% endfor %}
</ul>
{%- endmacro %}