I am writing a plugin that defines a new Jekyll block ditaa
. Any content in the block should be converted from Ditaa markup to an image file and that image inserted into the post instead of the block. Generating the file works but when copying into or generating in the _site
directory, the file is apparently deleted.
Is there a proper/better way to implement a block plugin that generates custom assets?
I've found the proper solution: use the Jekyll::StaticFile
class.
When you add one object of this class to the site.static_files
array, you are marking this file as pending for copy after the render process is completed. In fact, the copy of such files is done in the site.write
process. Take a look at the site_process.rb
file in your Jekyll installation.
The usage of this class is easy. When you need to mark a file for future copy, you simply execute a code like this:
site.static_files << Jekyll::StaticFile.new(site, site.source, path, filename)
Where path
and filename
depends on the location of your file in the src
folder.
I had a similar issue developing a LaTeX -> PNG liquid tag. You can take a look at my code at GitLab: https://gitlab.com/felix.galindo/jekyll-liquid-latex-plugin