olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.91k stars 546 forks source link

Integration to Jekyll #285

Closed Zujiry closed 7 years ago

Zujiry commented 7 years ago

Hello,

there might be a better platform to ask this but I have a question concerning the integration of lunr.js to Jekyll on github pages.

Everything works fine when I go over the posts via Json but if I do the same for pages:

{% for page in site.pages %} "{{ page.url | slugify }}": { "title": "{{ page.title | xml_escape }}", "content" : "{{page.content | strip_html | strip_newlines | remove: " " | escape | remove: "\"}}", "url": " {{ page.url | xml_escape }}", } {% endfor %}

resulting in _site to this:

"about": { "title": "Team", "content" : "Clownshawn", "url": " /about/", }

which looks okay to me. But adding this does seem to destroy the entire search progress. I am not able to debug this, so that is why I am asking here.

Could it be that lunr.js needs all of the parameters found in the json?

window.idx = lunr(function () { this.field('id'); this.field('title'); this.field('content', { boost: 10 }); this.field('author'); this.field('categories'); });

As there are no author or categories in the pages.

olivernn commented 7 years ago

There is a plugin for Jekyll for Lunr, it might help you with what you are doing.

But adding this does seem to destroy the entire search progress

What does this mean? Is there an error? What is the error?

Also what version of Lunr are you using?

Zujiry commented 7 years ago

Hey! Thanks for answering The plugin does not work well with github pages so that is why I wanted to try a different approach.

I followed this link to implement the search through a json file through which can be searched. And in the Gotchas (see link) there was the trick to simply add the code above, but! it broke the syntax of the json file I found out. So the error I meant was that the search simply did not work anymore as it did before with iterating through the posts of the site. What I am doing now is to simply search in my collections which works as wanted.

So the error was mine and not from lunr! Thank you for this wonderful search :) can be closed