2021-12-04 21:34:47 +01:00
|
|
|
{% macro list_posts(section=false, count=0, taxonomy=false) %}
|
|
|
|
{% if taxonomy == false and section != false %}
|
2021-12-04 18:30:05 +01:00
|
|
|
{% set section = get_section(path=section~"/_index.md") %}
|
|
|
|
{% endif %}
|
2021-12-02 11:53:48 +01:00
|
|
|
{% 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 %}
|
2021-12-04 19:10:58 +01:00
|
|
|
{{ self::print_article(page=page) }}
|
2021-12-02 11:53:48 +01:00
|
|
|
{% endfor %}
|
|
|
|
{% endmacro %}
|
|
|
|
|
|
|
|
{% macro print_article(page) %}
|
|
|
|
<article>
|
2021-12-04 22:05:33 +01:00
|
|
|
<h2><a href="{{ page.permalink }}">{{ page.title }}</a></h2>
|
2021-12-02 11:53:48 +01:00
|
|
|
<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) %}
|
2021-12-03 21:56:45 +01:00
|
|
|
{% 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">
|
2021-12-04 19:10:58 +01:00
|
|
|
{{ self::list_taxonomy(kind="categories", page=page.taxonomies.categories, prepend="#") }}
|
2021-12-04 18:05:15 +01:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-12-03 21:56:45 +01:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
2021-12-02 12:08:48 +01:00
|
|
|
{% endmacro %}
|
2021-12-03 22:59:23 +01:00
|
|
|
|
2022-09-22 11:59:17 +02:00
|
|
|
{% macro toc() %}
|
2022-09-22 12:09:41 +02:00
|
|
|
{% if page.toc and not page.extra.notoc %}
|
2022-09-22 11:59:17 +02:00
|
|
|
<ul>
|
|
|
|
{% for h1 in page.toc %}
|
|
|
|
<li>
|
|
|
|
<a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
|
|
|
|
{% if h1.children %}
|
|
|
|
<ul>
|
|
|
|
{% for h2 in h1.children %}
|
|
|
|
<li>
|
|
|
|
<a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
{% endmacro %}
|
|
|
|
|
2021-12-04 19:10:58 +01:00
|
|
|
{% macro list_taxonomy(kind, page=false, prepend="") %}
|
|
|
|
{#
|
|
|
|
Option `kind` must always be set and specifies the wanted taxonomy.
|
|
|
|
|
|
|
|
If `page` is set, this macro only prints items specific for this page.
|
|
|
|
Otherwise it prints all items. It expects `page.taxonomies.<taxonomy>`.
|
|
|
|
|
|
|
|
Option `prepend` can be used to prepend any string to the item name.
|
|
|
|
#}
|
2021-12-03 22:59:23 +01:00
|
|
|
<ul>
|
2021-12-04 19:10:58 +01:00
|
|
|
{% if page != false %}
|
|
|
|
{% for term in page %}
|
|
|
|
<li class="item"><a href="{{ get_taxonomy_url(kind=kind, name=term) | safe }}">{{ prepend }}{{ term }}</a></li>
|
|
|
|
{% endfor %}
|
|
|
|
{% else %}
|
|
|
|
{% set taxonomy = get_taxonomy(kind=kind) %}
|
|
|
|
{% for term in taxonomy.items %}
|
|
|
|
<li class="item"><a href="{{ term.permalink | safe }}">{{ prepend }}{{ term.name }}</a></li>
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2021-12-03 22:59:23 +01:00
|
|
|
</ul>
|
2021-12-04 19:10:58 +01:00
|
|
|
{% endmacro %}
|