Skip to content

Commit

Permalink
Liquid template tidy-up
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Apr 4, 2018
1 parent be7dca6 commit b899c78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
12 changes: 2 additions & 10 deletions _includes/datasets_display.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@

{% comment %}Only display datasets in current category if there is a current category{% endcomment %}
{% if current_category %}
{% assign current_slug = current_category | slugify %}
{% assign datasets = "" | split: "" %}
{% for s in site.datasets %}
{% capture slugs %}{% for category in s.categories %}{{category|slugify}}|{%endfor%}{%endcapture%}
{% assign site_slugs = slugs | split: "|" %}
{% if site_slugs contains current_slug %}
{% assign datasets = datasets | push: s %}
{% endif %}
{% endfor %}
{% assign datasets = site.datasets | where:"category", current_category %}
{% else %}
{% assign datasets = site.datasets %}
{% endif %}
Expand Down Expand Up @@ -41,7 +33,7 @@ <h3>Categories</h3>
{% endunless %}
{% endfor %}
<div class="js-hidden">
{% include filter-category.html categories=categories current=current_category %}
{% include filter-category.html categories=categories current_category=current_category %}
</div>
<div class="js-shown">
<a href="#" class="list-group-item list-show-more">Show {{ categories | size | plus: 1 }} more...</a>
Expand Down
10 changes: 5 additions & 5 deletions _includes/filter-category.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% comment %}All the below is so the list is sorted in descending size order. Ozymandias had nothing.{% endcomment %}
{% assign sizes = '' | split: "" %}
{% assign current_slug = current_category | slugify %}
{% assign current_slug = include.current_category | slugify %}
{% for category in include.categories %}
{% assign c = site.datasets | where:"category", category | size %}
{% assign sizes = sizes | push: c %}
Expand All @@ -11,10 +11,10 @@
{% assign c = sizes[forloop.index0] %}
{% if c == s %}
{% assign category_slug = category | slugify %}
<a href="/categories/{{ category | slugify }}" class="list-group-item {% if category_slug == current_slug %}active{% endif %}">
<span class="list-group-item-truncate">{{ category }}</span>
<span class="badge">{{ s }}</span>
</a>
<a href="/categories/{{ category | slugify }}" class="list-group-item {% if category_slug == current_slug %}active{% endif %}">
<span class="list-group-item-truncate">{{ category }}</span>
<span class="badge">{{ s }}</span>
</a>
{% endif %}
{% endfor %}
{% endfor %}
2 changes: 1 addition & 1 deletion _layouts/category.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
---

{% assign current_category = page.name %}
{% include datasets_display.html current_category=current_category %}
{% include datasets_display.html %}

0 comments on commit b899c78

Please sign in to comment.