{% 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 -%}
{% for s in topTerms %} {{ s | strip }}{% endfor %}