Entanglement
Entanglement

Reputation: 11

Jekyll istant search

I’m trying to implement the jekyll instant search from /Simple-Jekyll-Search found on Github (sorry can't post more than 2 link at the moment)

I followed all steps, I can see in _site the search.json file, is built correctly and being well formatted.

But no results output in the live site.

I have I tried to add the search code in _layout: default.html, and using a dedicated search.html page

---
layout: page
title: Search
---

<script src="{{ site.baseurl }}/search-script.js" type="text/javascript"></script>

<!-- Configuration -->
<script>
SimpleJekyllSearch({
  searchInput: document.getElementById('search-input'),
  resultsContainer: document.getElementById('results-container'),
  json: '/search.json'
})
</script>


<!-- Html Elements for Search -->
<div id="search-container">
<input type="text" id="search-input" placeholder="search...">
<ul id="results-container"></ul>
</div>

Inspect console shows this

js error

enter image description here

While I was doing some test, it worked for a while, but I’m not able to reproduce the conditions.

I think I make some mistakes in the structure of pages and the js is not correctly being called

I have a testsite here

realware

I'm quite sure I'm doing something wrong in the templating

Thanks for any help

Upvotes: 1

Views: 368

Answers (1)

Entanglement
Entanglement

Reputation: 11

Solved:

For future reference: the minified version contains some errors, I found a forked repo with a rebuilt version of the js, just remove the big comment block in the end of the file because links to external resources not needed and everything work like a charm

Use this repo, (not the minified versions)

https://github.com/tigerhawkvok/Simple-Jekyll-Search

Upvotes: 0

Related Questions