move search to its own file; fixes 1284
This commit is contained in:
parent
ac7d6024b3
commit
e6fc968cbd
2 changed files with 25 additions and 24 deletions
|
|
@ -8,32 +8,10 @@
|
|||
|
||||
<script src="https://unpkg.com/simple-jekyll-search@latest/dest/simple-jekyll-search.min.js"></script>
|
||||
<script>
|
||||
var searchjson = '[ \
|
||||
{% for post in site.posts %} \
|
||||
{ \
|
||||
"title" : "{% if post.title != "" %}{{ post.title | strip_html | escape | replace: "\", "\\\" }}{% else %}{{ post.excerpt | strip_html | escape | strip | replace: "\", "\\\" }}{%endif%}", \
|
||||
"desc" : "{% if post.title != "" %}{{ post.title | strip_html | escape | replace: "\", "\\\" }}{% else %}{{ post.excerpt | strip_html | escape | strip | replace: "\", "\\\" }}{%endif%}", \
|
||||
"category" : "{{ post.tags | join: \', \' }}", \
|
||||
"url" : "{{ site.baseurl }}{{ post.url | escape }}", \
|
||||
"date" : "{{ post.date | date: "%B %e, %Y" | default: "January 1, 1970" }}" \
|
||||
}, \
|
||||
{% endfor %} \
|
||||
{% for page in site.html_pages %}{% if page.title != "{title}" and page.title != "404 - Page not found" %} \
|
||||
{ \
|
||||
"title" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
|
||||
"desc" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
|
||||
"category" : "{% if page.tags %}{{ page.tags | join: \', \' }}{% else %}page{% endif %}", \
|
||||
"url" : "{{ site.baseurl }}{{ page.url }}", \
|
||||
"date" : "{{ page.date | date: '%B %e, %Y' | default: "January 1, 1970" }}" \
|
||||
}{% unless forloop.last %},{% endunless %} \
|
||||
{% endif %}{% endfor %} \
|
||||
]';
|
||||
searchjson = JSON.parse(searchjson);
|
||||
|
||||
var sjs = SimpleJekyllSearch({
|
||||
SimpleJekyllSearch({
|
||||
searchInput: document.getElementById('nav-search-input'),
|
||||
resultsContainer: document.getElementById('search-results-container'),
|
||||
json: searchjson
|
||||
json: '{{ site.baseurl }}/assets/data/searchcorpus.json'
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
|
|
|||
23
assets/data/searchcorpus.json
Normal file
23
assets/data/searchcorpus.json
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
layout: null
|
||||
---
|
||||
[
|
||||
{% for post in site.posts %}
|
||||
{
|
||||
"title" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}",
|
||||
"desc" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}",
|
||||
"category" : "{{ post.tags | join: ', ' }}",
|
||||
"url" : "{{ site.baseurl }}{{ post.url | escape }}",
|
||||
"date" : "{{ post.date | date: "%B %e, %Y" | default: "January 1, 1970" }}"
|
||||
},
|
||||
{% endfor %}
|
||||
{% for page in site.html_pages %}{% if page.title != "{title}" and page.title != "404 - Page not found" %}
|
||||
{
|
||||
"title" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}",
|
||||
"desc" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}",
|
||||
"category" : "{% if page.tags %}{{ page.tags | join: ', ' }}{% else %}page{% endif %}",
|
||||
"url" : "{{ site.baseurl }}{{ page.url }}",
|
||||
"date" : "{{ page.date | date: '%B %e, %Y' | default: "January 1, 1970" }}"
|
||||
}{% unless forloop.last %},{% endunless %}
|
||||
{% endif %}{% endfor %}
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue