1
0

Enable post-specific taxonomy listing

This commit is contained in:
Emil Miler 2021-12-04 19:10:58 +01:00
parent ae22681f18
commit 7009e50ce9

View File

@ -6,7 +6,7 @@
{% if loop.index > count and count != 0 %}
{% break %}
{% endif %}
{{ macros::print_article(page=page) }}
{{ self::print_article(page=page) }}
{% endfor %}
{% endmacro %}
@ -27,18 +27,32 @@
{% endif %}
{% if page.taxonomies.categories %}
<div class="taxonomy">
{{ self::list_taxonomy(kind="categories", prepend="#") }}
{{ self::list_taxonomy(kind="categories", page=page.taxonomies.categories, prepend="#") }}
</div>
{% endif %}
</div>
{% endif %}
{% endmacro %}
{% macro list_taxonomy(kind, prepend="") %}
{% 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.
#}
<ul>
{% 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 %}
{% 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 %}
</ul>
{% endmacro list_categories %}
{% endmacro %}