Skip to content

Commit

Permalink
Add option to search in specific collections (mmistakes#1369)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgarlis authored and mmistakes committed Nov 28, 2017
1 parent 42850ca commit b718bf7
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions assets/js/lunr-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ var idx = lunr(function () {
{% for c in site.collections %}
{% assign docs = c.docs %}
{% for doc in docs %}
idx.add({
title: {{ doc.title | jsonify }},
excerpt: {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
categories: {{ doc.categories | jsonify }},
tags: {{ doc.tags | jsonify }},
id: {{ count }}
});
{% assign count = count | plus: 1 %}
{% unless doc.search == false %}
idx.add({
title: {{ doc.title | jsonify }},
excerpt: {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
categories: {{ doc.categories | jsonify }},
tags: {{ doc.tags | jsonify }},
id: {{ count }}
});
{% assign count = count | plus: 1 %}
{% endunless %}
{% endfor %}
{% endfor %}

Expand All @@ -34,22 +36,24 @@ var store = [
{% endif %}
{% assign docs = c.docs %}
{% for doc in docs %}
{% if doc.header.teaser %}
{% capture teaser %}{{ doc.header.teaser }}{% endcapture %}
{% else %}
{% assign teaser = site.teaser %}
{% endif %}
{
"title": {{ doc.title | jsonify }},
"url": {{ doc.url | absolute_url | jsonify }},
"excerpt": {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
"teaser":
{% if teaser contains "://" %}
{{ teaser | jsonify }}
{% else %}
{{ teaser | absolute_url | jsonify }}
{% endif %}
}{% unless forloop.last and l %},{% endunless %}
{% unless doc.search == false %}
{% if doc.header.teaser %}
{% capture teaser %}{{ doc.header.teaser }}{% endcapture %}
{% else %}
{% assign teaser = site.teaser %}
{% endif %}
{
"title": {{ doc.title | jsonify }},
"url": {{ doc.url | absolute_url | jsonify }},
"excerpt": {{ doc.content | strip_html | truncatewords: 20 | jsonify }},
"teaser":
{% if teaser contains "://" %}
{{ teaser | jsonify }}
{% else %}
{{ teaser | absolute_url | jsonify }}
{% endif %}
}{% unless forloop.last and l %},{% endunless %}
{% endunless %}
{% endfor %}
{% endfor %}]

Expand Down

0 comments on commit b718bf7

Please sign in to comment.