manastech / middleman-search

LunrJS-based search for Middleman
MIT License
58 stars 31 forks source link

Problem indexing partials #14

Closed mukkoo closed 7 years ago

mukkoo commented 8 years ago

Hi,

using this gem I had a problem: the partials are not indexed.

Reading the code I've found (perhaps) the source of problem. In search-index-resource.rb:112 calling render() method with {:layout => false} the result doesn't contains any partials.

I haven't found any other resource method to have clean content with, already, partials.

The solution that I've found is Nokogiri side and not Middleman side.

I'll try to describe it:

search.exclude_html_classes = ['some_class', 'another_class']

What do you think about this solution?

If right I can work to a PR.

spalladino commented 8 years ago

Hi @mukkoo, thanks for the report!

It seems odd that Middleman skips partials when rendering without a layout. Though it seems to be the case when rendering in middleman-search, if I set a layout for a specific page to false in its frontmatter, then middleman displays it without layout but including partials (at least in version 3, I haven't tried 4).

Considering that, before going the Nokogiri way, I'd try to invest more time in figuring out what is causing middleman to skip partials in search-index-resource. If you want to tackle that, great; if not, I'll work on that some time during next week.

@matiasgarciaisaia what do you think?

matiasgarciaisaia commented 8 years ago

I don't really like the proposed alternative - seems too hacky for me :/

I'll second @spalladino - if middleman is behaving weird with partials, let's find out why. Rendering all the HTML just to get some part of it - it doesn't seem sensible.

Thanks for the catch, @mukkoo! Hope to give you good news soon :)

matiasgarciaisaia commented 7 years ago

Hi, @mukkoo - sorry for the delay.

We took some time with @spalladino to test this (you can check our test project), and - we couldn't repro the issue :(

We created a partial with a pretty much unique word, and middleman-search correctly indexed it.

I don't think it had to do with any of the changes we did in the gem, but check it - we may have fixed it, or who knows what's going on.

If you have any more info to share, we'll take another look later - during the next 2~7 months, perhaps 😛

spalladino commented 7 years ago

Closing after 1 month