--- # find and count unique subjects # # Requires CB's array_count_uniq.rb plugin! --- {%- if site.data.theme.subjects-fields -%} {%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid' -%} {%- assign subjects-fields = site.data.theme.subjects-fields | split: ";" -%} {%- assign subjects = "" -%} {%- for c in subjects-fields -%} {% assign new = items | map: c | join: ";" %} {% assign subjects = subjects | append: ";" | append: new %} {%- endfor -%} {%- assign uniqSubjects = subjects | downcase | split: ";" | array_count_uniq -%} { "subjects": [ {% for s in uniqSubjects %}{ "subject" : {{ s[0] | jsonify }}, "count" : {{ s[1] | jsonify }}, "link" : {{ s[0] | url_param_escape | prepend: '/browse/#' | absolute_url | jsonify }} }{% unless forloop.last %}, {% endunless %}{% endfor %} ]}{%- endif -%}