Add option to search in specific collections (#1369)

This commit is contained in:
Nick Garlis 2017-11-28 15:40:12 +02:00 committed by Michael Rose
parent a612808f2a
commit 599712ed58

View file

@ -14,6 +14,7 @@ var idx = lunr(function () {
{% for c in site.collections %} {% for c in site.collections %}
{% assign docs = c.docs %} {% assign docs = c.docs %}
{% 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 }},
@ -22,6 +23,7 @@ var idx = lunr(function () {
id: {{ count }} id: {{ count }}
}); });
{% assign count = count | plus: 1 %} {% assign count = count | plus: 1 %}
{% endunless %}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
@ -34,6 +36,7 @@ var store = [
{% endif %} {% endif %}
{% assign docs = c.docs %} {% assign docs = c.docs %}
{% 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 %}
@ -50,6 +53,7 @@ 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 %}]