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,14 +14,16 @@ 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 %}
idx.add({ {% unless doc.search == false %}
title: {{ doc.title | jsonify }}, idx.add({
excerpt: {{ doc.content | strip_html | truncatewords: 20 | jsonify }}, title: {{ doc.title | jsonify }},
categories: {{ doc.categories | jsonify }}, excerpt: {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
tags: {{ doc.tags | jsonify }}, categories: {{ doc.categories | jsonify }},
id: {{ count }} tags: {{ doc.tags | jsonify }},
}); id: {{ count }}
{% assign count = count | plus: 1 %} });
{% assign count = count | plus: 1 %}
{% endunless %}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
@ -34,22 +36,24 @@ var store = [
{% endif %} {% endif %}
{% assign docs = c.docs %} {% assign docs = c.docs %}
{% for doc in docs %} {% for doc in docs %}
{% if doc.header.teaser %} {% unless doc.search == false %}
{% capture teaser %}{{ doc.header.teaser }}{% endcapture %} {% if doc.header.teaser %}
{% else %} {% capture teaser %}{{ doc.header.teaser }}{% endcapture %}
{% assign teaser = site.teaser %} {% else %}
{% endif %} {% assign teaser = site.teaser %}
{ {% endif %}
"title": {{ doc.title | jsonify }}, {
"url": {{ doc.url | absolute_url | jsonify }}, "title": {{ doc.title | jsonify }},
"excerpt": {{ doc.content | strip_html | truncatewords: 20 | jsonify }}, "url": {{ doc.url | absolute_url | jsonify }},
"teaser": "excerpt": {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
{% if teaser contains "://" %} "teaser":
{{ teaser | jsonify }} {% if teaser contains "://" %}
{% else %} {{ teaser | jsonify }}
{{ teaser | absolute_url | jsonify }} {% else %}
{% endif %} {{ teaser | absolute_url | jsonify }}
}{% unless forloop.last and l %},{% endunless %} {% endif %}
}{% unless forloop.last and l %},{% endunless %}
{% endunless %}
{% endfor %} {% endfor %}
{% endfor %}] {% endfor %}]