Simplify search: true conditionals

Replace `unless` tags with `where_exp` to test if `search: false`.
This commit is contained in:
Michael Rose 2017-11-28 09:30:33 -05:00
parent 1fcda6f988
commit 7b3ddfefdf

View file

@ -12,9 +12,8 @@ var idx = lunr(function () {
{% assign count = 0 %} {% assign count = 0 %}
{% for c in site.collections %} {% for c in site.collections %}
{% assign docs = c.docs %} {% assign docs = c.docs | where_exp:'doc','doc.search != false' %}
{% for doc in docs %} {% for doc in docs %}
{% unless doc.search == false %}
idx.add({ idx.add({
title: {{ doc.title | jsonify }}, title: {{ doc.title | jsonify }},
excerpt: {{ doc.content | strip_html | truncatewords: 20 | jsonify }}, excerpt: {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
@ -23,7 +22,6 @@ var idx = lunr(function () {
id: {{ count }} id: {{ count }}
}); });
{% assign count = count | plus: 1 %} {% assign count = count | plus: 1 %}
{% endunless %}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
@ -34,9 +32,8 @@ var store = [
{% if forloop.last %} {% if forloop.last %}
{% assign l = true %} {% assign l = true %}
{% endif %} {% endif %}
{% assign docs = c.docs %} {% assign docs = c.docs | where_exp:'doc','doc.search != false' %}
{% for doc in docs %} {% for doc in docs %}
{% unless doc.search == false %}
{% if doc.header.teaser %} {% if doc.header.teaser %}
{% capture teaser %}{{ doc.header.teaser }}{% endcapture %} {% capture teaser %}{{ doc.header.teaser }}{% endcapture %}
{% else %} {% else %}
@ -53,7 +50,6 @@ var store = [
{{ teaser | absolute_url | jsonify }} {{ teaser | absolute_url | jsonify }}
{% endif %} {% endif %}
}{% unless forloop.last and l %},{% endunless %} }{% unless forloop.last and l %},{% endunless %}
{% endunless %}
{% endfor %} {% endfor %}
{% endfor %}] {% endfor %}]