{% comment %}

    Adds metadata to item pages in a description list element.
    Fields are configured via _data/config-metadata.csv 
    
{%- endcomment -%}
{%- assign fields = site.data.config-metadata | where_exp: 'item', 'item.display_name != nil' -%}
<div id="item-metadata">
    <dl>
        {% for f in fields %}{% if page[f.field] %}
        <dt class="field">{{ f.display_name }}:</dt>
        <dd class="field-value">
            {% if f.browse_link == "true" %}
            {% assign topics = page[f.field] | split: ";" %}
            {% for t in topics %}
            <a class="me-3" href="{{ t | strip | url_param_escape | prepend: ':' | prepend: f.field | prepend: '/browse/#' | relative_url }}">{{ t | strip }}</a>
            {% endfor %}
            {% elsif f.external_link == "true" %}
            <a href="{{ page[f.field] }}">{{ page[f.field] }}</a>
            {% else %}
            {{ page[f.field] | replace: '""','"' }}{% endif %}
        </dd>
        {% endif %}{% endfor %}
    </dl>
</div>