Initial commit

This commit is contained in:
Nasir Anthony Montalvo
2025-11-13 14:48:58 -06:00
committed by GitHub
commit 526096840e
2349 changed files with 19464 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
{% comment %}
Featured Terms button-links.
This include creates a card with btn links to the Browse page from a set of automatically generated or manually selected terms. Either use the "field" option to auto generate *or* the "featured" option to manually create list of terms.
E.G. --> {% include index/featured-terms.html field="subject" title="Top Subjects" btn-color="outline-info" max=8 %}
E.G. --> {% include index/featured-terms.html featured="Example term; Another; One more" title="Topic Areas" btn-color="success" %}
Options:
- "field" - a field from your metadata that will be used to auto generate top terms (required to auto generate)
- "featured" - a manually created list of featured terms, separated by ; semicolon (required if not auto generating from a field)
- "title" - card title text inside card content area (optional)
- "header" = card header text in bar above card content (optional)
- "heading_level" = customize the level of the heading if necessary for accessibility, choose "h1", "h2", "h3", etc (optional, default "h2")
- "max" - max number of terms to display if auto generating (optional, default 5)
- "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 "primary")
Requires CB's "array_count_uniq.rb" plugin!
{%- endcomment -%}
{% if include.featured %}
{% assign topTerms = include.featured | split: ";" %}
{%- else -%}
{% comment %}
Use termsField and termsMax to customize feature
{% endcomment %}
{% assign termsField = include.field | default: "subject" %}
{% assign termsMax = include.max | default: 5 %}
{% if site.data.theme.browse-child-objects == true %}
{%- assign terms = site.data[site.metadata] | where_exp: 'item','item.objectid' | map: termsField | join: ";" -%}
{% else %}
{%- assign terms = site.data[site.metadata] | where_exp: 'item','item.parentid == nil' | map: termsField | join: ";" -%}
{%- endif -%}
{%- assign uniqTerms = terms | downcase | split: ";" | array_count_uniq -%}
{% capture topTerms %}
{% for i in uniqTerms limit: termsMax %}{{ i[0] }};{% endfor %}{% endcapture %}
{% assign topTerms = topTerms | split: ";" %}
{%- endif -%}
<div class="card mb-3">
{% if include.header %}<{{ include.heading_level | default: 'h2' | strip }} class="card-header h5">{{ include.header }}</{{ include.heading_level | default: 'h2' | strip }}>{% endif %}
<div class="card-body">
{% if include.title %}<{{ include.heading_level | default: 'h2' | strip }} class="card-title h5">{{ include.title }}</{{ include.heading_level | default: 'h2' | strip }}>{% endif %}
<p class="card-text">
{% for s in topTerms %}
<a class="btn btn-sm btn-{{ include.btn-color | default: 'primary' }} m-1" href="{{ s | strip | url_param_escape | prepend: ':' | prepend: termsField | prepend: '/browse.html#' | relative_url }}">{{ s | strip }}</a>{% endfor %}
</p>
</div>
</div>