middleman / middleman-asciidoc

:beginner: AsciiDoc support for Middleman 4. (In Middleman 3, AsciiDoc support is provided by a core extension).
https://middlemanapp.com
Other
27 stars 12 forks source link

Error when using middleman-search with directory indexes #90

Open lask79 opened 5 years ago

lask79 commented 5 years ago

In my current setup I am trying to use middleman-search together with directory indexes and asciidoc.

While using that I am getting this error: undefined method destination_path' for nil:NilClass C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/middleman-asciidoc-1.0.0/lib/middleman-asciidoc/template.rb:14:inprepare' C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/tilt-2.0.8/lib/tilt/template.rb:99:in initialize' C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/tilt-2.0.8/lib/tilt/mapping.rb:138:innew' C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/tilt-2.0.8/lib/tilt/mapping.rb:138:in new' C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/tilt-2.0.8/lib/tilt.rb:43:innew'

The problem is that the current page that needs to be rendered by asciidoc is not having a resource but only the :current_path. middleman-search runs through the sitemap and renderes all found resources like this:

https://github.com/manastech/middleman-search/blob/master/lib/middleman-search/search-index-resource.rb

html = resource.render( { :layout => false }, { :current_path => resource.path } )
Nokogiri::HTML(html).xpath("//text()").text

The problem is that some of the resources in the sitemap are not found by the TemplateContext.current_resource by the :current_path when directory index is used.

Is it possible to change the middleman-asciidoc to render also by the provided path and not by calling resource.destination_path anymore when there is no resource?

Regards Lasse