{% macro taxonomy_links(terms, kind) -%}
    {%- for term in terms -%}
        {%- if not loop.first %}, {% endif -%}
        <a href="{{ get_taxonomy_url(kind=kind, name=term) | safe }}">{{ term }}</a>
    {%- endfor -%}
{%- endmacro taxonomy_links %}

{% macro taxonomy_nav(kind, heading_id, title, description, path, link_label) %}
{% set taxonomy = get_taxonomy(kind=kind, required=false) %}
{% if taxonomy and taxonomy.items %}
<nav class="section-tools" aria-labelledby="{{ heading_id }}">
    <div>
        <h2 id="{{ heading_id }}">{{ title }}</h2>
        <p>{{ description }}</p>
    </div>
    <a class="section-tools__link" href="{{ get_url(path=path, trailing_slash=true) | safe }}">
        {{ link_label }}
    </a>
</nav>
{% endif %}
{% endmacro taxonomy_nav %}

{% macro metadata_field(extra, key, label, lang="") -%}
    {%- set value = extra | get(key=key, default="") -%}
    {%- if value -%}
        <dt>{{ label }}</dt>
        <dd{% if lang %} lang="{{ lang }}"{% endif %}>{{ value }}</dd>
    {%- endif -%}
{%- endmacro metadata_field %}

{% macro metadata_list(extra, key, label, lang="") -%}
    {%- set values = extra | get(key=key, default="") -%}
    {%- if values -%}
        <dt>{{ label }}</dt>
        <dd{% if lang %} lang="{{ lang }}"{% endif %}>
            {%- for value in values -%}
                {%- if not loop.first %}, {% endif -%}
                {{- value -}}
            {%- endfor -%}
        </dd>
    {%- endif -%}
{%- endmacro metadata_list %}

