Writing a Plugin
A plugin should export a plain JavaScript object
(#1
). If the plugin needs to take options, it can be a function that returns a plain object(#2
). The function will be called with the plugin’s options as the first argument, along with ctx which provides some compile-time metadata.
// #1
module.exports = {
// ...
}
// #2
module.exports = (options, ctx) => {
return {
// ...
}
}
TIP
A KduPress plugin module should be a CommonJS Module
because KduPress plugins runs on the Node.js side.