Extension that creates files without a source

I’m struggling here to create an extension that generates some pages from a few complex yaml files. I had this working in Jekyll but I am trying to move to middleman. I have generated a new extension and am trying to figure out how to add a file to the sitemap with a resource_list_manipulator. I create a new resource but it throws an error when i try to see my site map because i have no source_file. The problem is… there isn’t really a source file… or the source file is rather 3 yaml files in data/ . Any thoughts on how to tackle this or suggestions of extensions doing something similar that I can take a look at?

Thanks.

Frustrating. But a workaround maybe is to add a source file?

See Pass dynamic content to template in Middleman

You have two options. Either ship a source template with your extension, and pass that as the source file, or create a new subclass of Sitemap::Resource that has its own render method that does what you want.

I’ll check out the 2nd option here. I’m trying to create an iCal (.ics) file. I have code that already generates it (from a jekyll site I built). Anyway, it isn’t from a template so sounds like the second option will get me what I need. Thanks for the pointer

This worked great. I also had to override the following:

def source_file
  ""
end
def binary?
  false
end
1 Like