Останній костиль у блог - пошук по сайту. Є 3 варіанти: Google Custom Search Engine, Lunr.js та Simple Jekyll Search. Lunr читав має проблеми з пошуком на кирилиці, тому не видумуючи велосипед для початку пробую використовувати те що вже є в самому jekyll
Зроблено по статті .
---
---
[
{% for post in site.posts %}
{
"title" : "{{ post.title | escape }}",
"url" : "{{ site.baseurl }}{{ post.url }}",
"category" : "{{ post.category }}",
"tags" : "{{ post.tags | join: ', ' }}",
"date" : "{{ post.date }}"
} {% unless forloop.last %},{% endunless %}
{% endfor %}
]
<!-- Html Elements for Search -->
<div id="search-container">
<input type="text" id="search-input" placeholder="search...">
<ul id="results-container">
</div>
<!-- Script pointing to search-script.js -->
<script src="/path/to/search-script.js" type="text/javascript"></script>
<!-- Configuration -->
<script>
SimpleJekyllSearch({
searchInput: document.getElementById('search-input'),
resultsContainer: document.getElementById('results-container'),
json: '/search.json'
})
</script>
Готово.