Skip to content

Commit e6fc968

Browse files
committed
move search to its own file; fixes 1284
1 parent ac7d602 commit e6fc968

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

_includes/search.html

+2-24
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,10 @@
88

99
<script src="https://unpkg.com/simple-jekyll-search@latest/dest/simple-jekyll-search.min.js"></script>
1010
<script>
11-
var searchjson = '[ \
12-
{% for post in site.posts %} \
13-
{ \
14-
"title" : "{% if post.title != "" %}{{ post.title | strip_html | escape | replace: "\", "\\\" }}{% else %}{{ post.excerpt | strip_html | escape | strip | replace: "\", "\\\" }}{%endif%}", \
15-
"desc" : "{% if post.title != "" %}{{ post.title | strip_html | escape | replace: "\", "\\\" }}{% else %}{{ post.excerpt | strip_html | escape | strip | replace: "\", "\\\" }}{%endif%}", \
16-
"category" : "{{ post.tags | join: \', \' }}", \
17-
"url" : "{{ site.baseurl }}{{ post.url | escape }}", \
18-
"date" : "{{ post.date | date: "%B %e, %Y" | default: "January 1, 1970" }}" \
19-
}, \
20-
{% endfor %} \
21-
{% for page in site.html_pages %}{% if page.title != "{title}" and page.title != "404 - Page not found" %} \
22-
{ \
23-
"title" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
24-
"desc" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
25-
"category" : "{% if page.tags %}{{ page.tags | join: \', \' }}{% else %}page{% endif %}", \
26-
"url" : "{{ site.baseurl }}{{ page.url }}", \
27-
"date" : "{{ page.date | date: '%B %e, %Y' | default: "January 1, 1970" }}" \
28-
}{% unless forloop.last %},{% endunless %} \
29-
{% endif %}{% endfor %} \
30-
]';
31-
searchjson = JSON.parse(searchjson);
32-
33-
var sjs = SimpleJekyllSearch({
11+
SimpleJekyllSearch({
3412
searchInput: document.getElementById('nav-search-input'),
3513
resultsContainer: document.getElementById('search-results-container'),
36-
json: searchjson
14+
json: '{{ site.baseurl }}/assets/data/searchcorpus.json'
3715
});
3816
</script>
3917
</div>

assets/data/searchcorpus.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
layout: null
3+
---
4+
[
5+
{% for post in site.posts %}
6+
{
7+
"title" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}",
8+
"desc" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}",
9+
"category" : "{{ post.tags | join: ', ' }}",
10+
"url" : "{{ site.baseurl }}{{ post.url | escape }}",
11+
"date" : "{{ post.date | date: "%B %e, %Y" | default: "January 1, 1970" }}"
12+
},
13+
{% endfor %}
14+
{% for page in site.html_pages %}{% if page.title != "{title}" and page.title != "404 - Page not found" %}
15+
{
16+
"title" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}",
17+
"desc" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}",
18+
"category" : "{% if page.tags %}{{ page.tags | join: ', ' }}{% else %}page{% endif %}",
19+
"url" : "{{ site.baseurl }}{{ page.url }}",
20+
"date" : "{{ page.date | date: '%B %e, %Y' | default: "January 1, 1970" }}"
21+
}{% unless forloop.last %},{% endunless %}
22+
{% endif %}{% endfor %}
23+
]

0 commit comments

Comments
 (0)