Closed kitsunde closed 9 years ago
It's a generator you want, the documentation is perhaps a little unclear, the note is because you shouldn't modify the tree passed into a generator but instead return a object with keys corresponding to the files you want to add and they will be merged.
env.registerGenerator 'sitemap', (contents, callback) ->
rv = {'mysitemap.xml': somePluginInstance}
callback null, rv
I have 2 use cases for this.
The first is to build a
sitemap.xml
of page metadata, currently I've done that by dropping files into thecontent/
andtemplate/
folder and doing some rather ugly recursive macro calls with nunjucks on the context.The second is to build a
search.json
file for lunr.js by similarly crawling over the metadata.It seems like both
ContentPlugin
andTemplatePlugin
matches against existing files.Generator
isn't supposed to modify the tree according to https://github.com/jnordberg/wintersmith/wiki/Writing-plugins#envregistergeneratorcontentgroup-generatorfnIt's not clear to me how to accomplish this.