wildlyinaccurate / jekyll-responsive-image

An unopinionated Jekyll plugin for generating and using responsive images
MIT License
332 stars 48 forks source link

Build problem - run order? #17

Closed n3tfl0w closed 8 years ago

n3tfl0w commented 8 years ago

Hi,

First off - please forgive this rambling issue text. Secondly, I'm pretty sure this isn't an issue with your excellent plugin but with my limited ruby knowledge but I thought I'd check.

Quick bit of background. I wrote quick and dirty generator plugin to duplicate every post but with a slightly different name for AMP (index.amp.html). It applies a different template and does some text replacement. I have another quick plugin to replace the markdown implementation of imgs to your required liquid tag.

To the crux of my problem, it wont apply to the second plugin-generated file in my build process. Is it because of the build order (i.e. when plugins or gems get executed) or because there's some coding that I don't understand in your plugin?

So I have a index.html and index.amp.html and they both have the responsive liquid tag but only the index.html gets replaced by your plugin. Is it because the gem is executed before the plugin because the gem is more closely integrated with the actual Jekyll build?

n3tfl0w commented 8 years ago

I think I see my problem now, because the plugin is tightly integrated with the actual site render, it has no idea that my extra files have been created - your plugin is not going through output and replacing content, it's actually doing the render. I'll figure something out. Again - really like the plugin. Thanks for taking the time to write it.

wildlyinaccurate commented 8 years ago

Are any other liquid tags being replaced in the *.amp.html files? If not, then it's probably that the files are being created too late for Jekyll to pick them up. But if they are, then you might be able to get around it by raising the priority of the generators.

n3tfl0w commented 8 years ago

Yeah, I can get jekyll to render it the page ok with this kind of hacked together code:

def generate(site) site.posts.each do |post| if post.data["layout"] == 'article' post.data["layout"] = "articleamp" post.render(site.layouts, site.site_payload) post.write(site.dest, "index.amp.html") post.data["layout"] = 'article' end end end

But it seems to pay no attention at all to your enhanced render. No worries, I'll figure something out on my grunt workflow side to do something.

n3tfl0w commented 8 years ago

Weirdly - and I have no idea why but blind luck had me run the generate again in the same loop. And its working. I have literally no clue why. But gift horses and all.