guard-jekyll-plus icon indicating copy to clipboard operation
guard-jekyll-plus copied to clipboard

handle _data files / dir?

Open jm3 opened this issue 9 years ago • 3 comments

does this handle files in the _data dir? jekyll doesn't seem to handle these so well, presumably because it doesn't know which templates depend on which data files. i was hoping for something that would just rebuild everything when a data file changes.

jm3 avatar Feb 02 '16 06:02 jm3

This plugin watches everything except changes in the output directory (usually _site):

https://github.com/imathis/guard-jekyll-plus/blob/master/lib/guard/jekyll_plus/config.rb#L95

So it does watch the data directory, but it depends how jekyll build responds.

Since jekyll doesn't know which data files affect which files, you can manually add "fake" guard triggers for each dependent file in your Guardfile, e.g.:

require 'guard/jekyll_plus/config'
jekyll_plus_options = {}
guard 'jekyll-plus', jekyll_plus_options do
  watch(Guard::JekyllPlus::Config.new(jekyll_plus_options).watch_regexp)
  watch('_data/stuff.yml') { ['src/foo.html', 'src/bar.html'].each { |f| system("touch", f } }
end

This may confuse your editor, but it's better than nothing.

Otherwise, Jekyll would have to have a "dependency" mode, where it processes a file and only lists dependencies (instead of actually processing the file).

e2 avatar Feb 02 '16 20:02 e2

oh wow, that's awesome. thanks!

@e2 i'm curious, have you seen your plugin used to make jekyll generate source maps? I've had some difficulty doing so — this issue explains why it's non-trivial

jm3 avatar Feb 04 '16 19:02 jm3

Hey, I've run into a similar issue when editing ruby files in the _plugins directory. I expect this has the same underlying cause of jekyll build not knowing which files to build.

Would it be possible to trigger a full jekyll build for certain files such as _data/* and _plugins/*?

I'm happy to take a stab at it if it seems like a good idea.

devm33 avatar Feb 20 '18 02:02 devm33