jekyll / jekyll-redirect-from

:twisted_rightwards_arrows: Seamlessly specify multiple redirections URLs for your pages and posts.
MIT License
780 stars 112 forks source link

Calling 'site.docs_to_write' prevents other generators from working properly #199

Closed radoslavkarlik closed 5 years ago

radoslavkarlik commented 5 years ago

Calling site.docs_to_write in generator.rb will make the site object remember the result of the first call which means that content generated later from other generators will not be taken into consideration. Took me a lot of time to figure out why is my content not being generated anymore.

ashmaroli commented 5 years ago

@RadoslavK What version of Jekyll are you using..?

radoslavkarlik commented 5 years ago

@ashmaroli 3.8.5, I have fixed the issue with a higher plugin priority so my content is being generated before the docs_to_write is called

ashmaroli commented 5 years ago

This is probably because of the caching incorporated into the method:

    # Get the to be written documents
    #
    # Returns an Array of Documents which should be written
    def docs_to_write
      @docs_to_write ||= documents.select(&:write?)
    end
radoslavkarlik commented 5 years ago

I am not sure why Jekyll allows calling that method from the outside. Maybe you could rethink the usage of documents.select(&:write?) directly, so any other generator's new documents are not omitted unless jekyll-redirect-from is called last. Jekyll internally calls docs_to_write when writing the final output.

DirtyF commented 5 years ago

This should be fixed in Jekyll core.