From b718bf75965739cb9a7f0d42f46de2c1d9a28386 Mon Sep 17 00:00:00 2001 From: Nick Garlis Date: Tue, 28 Nov 2017 15:40:12 +0200 Subject: [PATCH] Add option to search in specific collections (#1369) --- assets/js/lunr-en.js | 52 ++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/assets/js/lunr-en.js b/assets/js/lunr-en.js index d196d5543037..b4d1b7b694de 100644 --- a/assets/js/lunr-en.js +++ b/assets/js/lunr-en.js @@ -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 %} @@ -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 %}]