New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lunr search - doesn't index _pages? #1409

Closed
Sciss opened this Issue Dec 17, 2017 · 9 comments

Comments

Projects
None yet
4 participants
@Sciss

Sciss commented Dec 17, 2017

  • This is a question about using the theme.
  • This is a feature request.
  • I believe this to be a bug with the theme.
    • I have updated all gems with bundle update.
    • I have tested locally with bundle exec jekyll build.

Information

The site search is a great feature; I can't find much info here, though: https://mmistakes.github.io/minimal-mistakes/docs/configuration/#site-search - simply enabling search: true in _config.yml makes it possible to search through _posts, but it doesn't seem to index _pages.

How can I make the search feature include all texts in _pages as well?

@mmistakes

This comment has been minimized.

Show comment
Hide comment
@mmistakes

mmistakes Dec 17, 2017

Owner

Currently only supports posts and collections. You'd have to alter the code to index pages as well.

https://github.com/mmistakes/minimal-mistakes/blob/master/assets/js/lunr-en.js

Owner

mmistakes commented Dec 17, 2017

Currently only supports posts and collections. You'd have to alter the code to index pages as well.

https://github.com/mmistakes/minimal-mistakes/blob/master/assets/js/lunr-en.js

@Sciss

This comment has been minimized.

Show comment
Hide comment
@Sciss

Sciss Dec 18, 2017

Thank you; I could use collections now. It's worth noting - perhaps you can add that info to the guide - that lunr breaks if you use a number as a tag. I had this:

tags: [installation, 2015]

and this causes a JavaScript error t.toLowerCase is not a function. Changing to

tags: [installation, "2015"]

makes it work.

Sciss commented Dec 18, 2017

Thank you; I could use collections now. It's worth noting - perhaps you can add that info to the guide - that lunr breaks if you use a number as a tag. I had this:

tags: [installation, 2015]

and this causes a JavaScript error t.toLowerCase is not a function. Changing to

tags: [installation, "2015"]

makes it work.

@mmistakes

This comment has been minimized.

Show comment
Hide comment
@mmistakes

mmistakes Dec 18, 2017

Owner

Looks like the version of Lunr.js included (0.5.12) with the theme is super old. It's currently at 2.1.5 so perhaps this issue has been fixed.

@nickgarlis Any particular reason you used an older version of Lunr? I did a quick test by updating to the current version and I get Uncaught TypeError: idx.add is not a function, so guessing the API changed slightly. Wondering if we can update since with any sort of functionality/performance gains. Thoughts?

Owner

mmistakes commented Dec 18, 2017

Looks like the version of Lunr.js included (0.5.12) with the theme is super old. It's currently at 2.1.5 so perhaps this issue has been fixed.

@nickgarlis Any particular reason you used an older version of Lunr? I did a quick test by updating to the current version and I get Uncaught TypeError: idx.add is not a function, so guessing the API changed slightly. Wondering if we can update since with any sort of functionality/performance gains. Thoughts?

@mmistakes

This comment has been minimized.

Show comment
Hide comment
@mmistakes
Owner

mmistakes commented Dec 18, 2017

@nickgarlis

This comment has been minimized.

Show comment
Hide comment
@nickgarlis

nickgarlis Dec 18, 2017

Contributor

@mmistakes I think it had something to do with the custom stemmer that I use to support Greek characters. The error that you get must be because Lunr now gets the documents added in the configuration function. Other than that, I think that upgrading is a good idea and it is something that I had in mind. I will run some tests and if everything works properly, I can pull request the upgrade.

Contributor

nickgarlis commented Dec 18, 2017

@mmistakes I think it had something to do with the custom stemmer that I use to support Greek characters. The error that you get must be because Lunr now gets the documents added in the configuration function. Other than that, I think that upgrading is a good idea and it is something that I had in mind. I will run some tests and if everything works properly, I can pull request the upgrade.

@mmistakes

This comment has been minimized.

Show comment
Hide comment
@mmistakes

mmistakes Dec 18, 2017

Owner

Sounds good @nickgarlis 😀

Owner

mmistakes commented Dec 18, 2017

Sounds good @nickgarlis 😀

@nickgarlis

This comment has been minimized.

Show comment
Hide comment
@nickgarlis

nickgarlis Dec 27, 2017

Contributor

I just pull requested the update #1419 . Lunr will not break if you use numbers as tags now. Also, Lunr is now configured to search for every word inside of the query string and not just for the whole string.

Contributor

nickgarlis commented Dec 27, 2017

I just pull requested the update #1419 . Lunr will not break if you use numbers as tags now. Also, Lunr is now configured to search for every word inside of the query string and not just for the whole string.

@mmistakes mmistakes closed this Dec 28, 2017

@Aaronius

This comment has been minimized.

Show comment
Hide comment
@Aaronius

Aaronius Apr 24, 2018

If anyone has a modified lunr file that supports pages, I'd sure appreciate a copy. ❤️

Aaronius commented Apr 24, 2018

If anyone has a modified lunr file that supports pages, I'd sure appreciate a copy. ❤️

@mmistakes

This comment has been minimized.

Show comment
Hide comment
@mmistakes

mmistakes Apr 24, 2018

Owner

@Aaronius The Lunr index currently loops through collections documents (... posts). Here's the relevant code. To add pages to the mix you'd have to loop through site.pages as well.

For a better search experience I'd suggest using Algolia instead.

And if you need an example of how to set it up check out this repo.

Owner

mmistakes commented Apr 24, 2018

@Aaronius The Lunr index currently loops through collections documents (... posts). Here's the relevant code. To add pages to the mix you'd have to loop through site.pages as well.

For a better search experience I'd suggest using Algolia instead.

And if you need an example of how to set it up check out this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment