{% comment %}

    Adds button links for compound object parent item page. 
    If item has date to Timeline, if item has lat/long to Map, if item has child objects with object_location it adds Download options for each.
    Styled as a Bootstrap btn-group.

{%- endcomment -%}
<div class="btn-group my-3" role="group" aria-label="Item options">
    {% if page.object_transcript %}<button class="btn btn-outline-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTranscript" aria-expanded="false" aria-controls="collapseTranscript">View Transcript</button>{% endif %}
    {% if page.date %}{%- capture year -%}{% if page.date contains "-" %}{{ page.date | split: "-" | first }}{% elsif page.date contains "/" %}{{ page.date | split: "/" | last }}{% else %}{{ page.date }}{% endif %}{%- endcapture -%}
    <a href="{{ year | strip | prepend: '/timeline.html#y' | relative_url }}" class="btn btn-outline-primary">View on Timeline</a>{% endif %}
    {% if page.latitude and page.longitude %}
    <a href="{{ '/map/?location=' | append: page.latitude  | append: ',' | append: page.longitude | append: '&marker=' | append: page.objectid | relative_url }}" class="btn btn-outline-primary">View on Map</a>{% endif %}

    <div class="btn-group" role="group">
        <button class="btn btn-outline-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
            Download
        </button>
        <ul class="dropdown-menu">
            {% if page.object_location %}<li><a target="_blank" rel="noopener" href="{{ page.object_location | relative_url }}" class="dropdown-item">{{ page.title }} ({{ page.format | split: '/' | last | upcase }})</a></li>{% endif %}
            {% for child in children %}
            {% unless child.object_location == nil %}
            <li>
                <a target="_blank" rel="noopener" href="{{ child.object_location | relative_url }}" class="dropdown-item">
                    {% if page.title != child.title and child.title != nil %}{{ child.title | truncatewords: 3 }}{% else %}Item {{ forloop.index }}{% endif %}
                    {% if child.format %}({{ child.format | split: '/' | last | upcase }}){% endif %}
                </a>
            </li>
            {% endunless %}
            {% endfor %}
        </ul>
    </div>
</div>
{% if page.object_transcript %}
<div class="collapse mt-3" id="collapseTranscript">
    <div class="card card-body text-start">
        {% assign transcript_type = page.object_transcript | slice: 0,1 %}
        {% if transcript_type == '/' %}
        {% assign transcript_location = page.object_transcript | remove_first: '/' %}
        {% assign transcript = site.pages | where: 'path', transcript_location | first %}
        {{ transcript.content | markdownify }}
        {% else %}
        {{ page.object_transcript | markdownify }}
        {% endif %}
    </div>
</div>
{% endif %} 