Files
bqkc/_includes/index/content.html
Nasir Anthony Montalvo 526096840e Initial commit
2025-11-13 14:48:58 -06:00

47 lines
2.9 KiB
HTML

{% comment %}
Collection content summary.
Counts item types based on "display_template" providing link to Browse page.
E.G. --> {% include index/content.html %}
E.G. --> {% include index/content.html object_field="format" others=true total=true %}
Options:
- "btn-color" - a bootstrap color class to theme the buttons. Can be any bootstrap template color (e.g. info, success) or outline (e.g. outline-info, outline-success), including colors created in config-theme-colors. (optional, default "outline-secondary")
- "heading_level" = customize the level of the heading if necessary for accessibility, choose "h1", "h2", "h3", etc (optional, default "h2")
- "object_field" = optionally change the field used to count items. Typically this is either "display_template" (default) or "format". The field should be available on the Browse page to filter! The icons assume you use something like "display_template" or "format" to select the correct icon.
- "child-objects" = include child items in count or only parents, true or false (optional, default false)
- "others" = display a count for items with no "display_template", true or false (optional, default false)
- "total" = display a count for total items, true or false (optional, default false)
{%- endcomment -%}
{%- assign object_field = include.object_field | default: 'display_template' -%}
{% if include.child-objects == true %}
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid' -%}
{% else %}
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid and item.parentid == nil' -%}
{% endif %}
{%- assign templates = items | map: object_field -%}
{%- assign types = templates | uniq | compact | sort -%}
<div class="card mb-3" >
<div class="card-body">
<{{ include.heading_level | default: 'h2' | strip }} class="card-title h5">Content</{{ include.heading_level | default: 'h2' | strip }}>
<p class="card-text">
{% for t in types %}
{%- assign count = templates | where_exp: 'item', 'item contains t' | size -%}
{% if count > 0 %}
{{ count }}
<a class="text-dark" href="{{ '/browse.html' | relative_url }}#display_template:{{ t }}">{{ t | upcase | replace: "_", " " }}
{% include helpers/get-icon-svg.html type="hidden" template=t %}</a><br>
{%- endif -%}
{%- endfor -%}
{% if include.others == true %}{% assign others = templates | where_exp: 'item', 'item == nil or item == ""' | size %}{% if others > 0 %}
{{ others }} OTHER {% include helpers/get-icon-svg.html type="hidden" %}<br>{% endif %}{% endif %}
{% if include.total == true %}
{{ templates | size }} TOTAL ITEMS<br>{% endif %}
<a class="btn btn-sm btn-{{ include.btn-color | default: 'outline-secondary' }} mt-2" href="{{ '/data.html' | relative_url }}">View table</a>
</p>
</div>
</div>