This script provides a simple way to add filters to a page within Jekyll. It's intended to be used with data files or collections, as well as custom JSON. Currently not tested very thoroughly so it might not work exactly as intended.
---
layout: none
---
{
"template": "/ajax/company_list.html", # this is include for your entry
"entries": [
{% for item in site.data.companies %}
{{ item | jsonify }}
{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
<div class="company">
<h3>
{% if img != null %}
<img src="/images/company/{{ img }}">
{% endif %}
{% if url != null %}<a href="{{ url }}">{{ company }}</a>{% else %}{{ company }}{% endif %}: ${{ roundsize }} million - {{ round }}</h3>
<h4>
{{ date }} | {{ classification }}
</h4>
{% if description != null %}<p><b>Description:</b> {{ description }}</p>{% endif %}
<p><b>Investors:</b> {{ investors }}</p>
<p><b>Headquartered:</b> {{ headquartered }}</p>
<p><b>Country:</b> {{ country }}</p>
</div>
<div class="filters">
<!-- Automatically populated and ordered selector -->
<b>Country:</b> <select id="country" data-type="country"></select></br>
<!-- Predefined selector -->
<b>State:</b>
<select id="state">
<option>All</option>
<option>Texas</option>
<option>Alabama</option>
<option>Florida</option>
</select>
</div>
<div class="filters-content">
<!-- Here you can put a loop to display your data. The existing data will be overriden after the filter is used for the first time -->
</div>
filter.init('/ajax/company_list.json');