Much of the built in functionality in Sitegen is implemented by plugins. You can create your own plugins to add custom functionality to the various steps of building the site. A plugin is implemented as a MoonScript class. Functionality is injected into the build by implemending certain properties or methods. The Plugin Lifecycle describes what happens to a plugin when Sitegen builds the site.
site.moon
…
mixin_funcs
property:
mixin_funcs
is copied to the site’s config scope. These methods can be called from site.moon
, they are bound to the instance of the plugintype_name
property:
is_a
property:
type_name
matching a value in is_a
are called via the on_aggregate
method. The current page is passed to the method as the first argumenttpl_helpers
property:
tpl_helpers
is made available to be called in any template, the methods are bound the instance of the plugin. They will also receive an instance of a page before any arguments passed to the method.write
method are called. The write
method is called with no arguments. This is when a plugin can create any necessary side effect filessite scope: the object that represents the function environment that is
used when running the initialize function. The mixin_funcs
property on a
plugin is used to extend this scope.
template scope: the object that holds all the fields available to any
template rendered for that page. The tpl_helpers
property on a plugin is used
to extend this scope.