-
Notifications
You must be signed in to change notification settings - Fork 335
Writing plugins
You can fork this handy template as a base for your plugin https://github.com/jnordberg/wintersmith-plugin
Wintersmith plugins are packaged as node.js modules, they are expected to export a function that accepts a environment and callback argument.
function plugin(env, callback) { }
The env
is your wintersmith site's environment, at this point no content or templates are loaded. The callback should be called when the plugin has finished loading or when an error occurs.
Add a content plugin to the environment. Files in the contents directory matching the glob pattern will be instanciated using the plugin's fromFile factory method. The group argument is used to group the loaded instances under each directory. I.e. plugin instances with the group 'textFiles' can be found in contents.somedir._.textFiles.
Add a template plugin to the environment. All files in the template directory matching the glob pattern will be passed to the plugin's fromFile classmethod.
Add a generator to the environment. The generator function is called with the env and the current content tree. It should return a object with nested ContentPlugin instances. These will be merged into the final content tree.
function generator(contents, callback) { }
NOTE: do not modify the content tree directly in a generator, consider it read-only.
Add a reusable view to the environment. More on views: TODO
Namespace that can be used to hold helper functions etc used by plugins