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 %} {% if loop.index > count and count != 0 %}
{% break %} {% break %}
{% endif %} {% endif %}
{{ macros::print_article(page=page) }} {{ self::print_article(page=page) }}
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}
@ -27,18 +27,32 @@
{% endif %} {% endif %}
{% if page.taxonomies.categories %} {% if page.taxonomies.categories %}
<div class="taxonomy"> <div class="taxonomy">
{{ self::list_taxonomy(kind="categories", prepend="#") }} {{ self::list_taxonomy(kind="categories", page=page.taxonomies.categories, prepend="#") }}
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
{% endmacro %} {% 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> <ul>
{% 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) %} {% set taxonomy = get_taxonomy(kind=kind) %}
{% for term in taxonomy.items %} {% for term in taxonomy.items %}
<li class="item"><a href="{{ term.permalink | safe }}">{{ prepend }}{{ term.name }}</a></li> <li class="item"><a href="{{ term.permalink | safe }}">{{ prepend }}{{ term.name }}</a></li>
{% endfor %} {% endfor %}
{% endif %}
</ul> </ul>
{% endmacro list_categories %} {% endmacro %}