Create a plugin!
-
@julian Is this the newest way to write a plugin!
https://nodebb.readthedocs.io/en/latest/plugins/create.html
I get confused because i see code that uses
plugin.load = function (data, next) { ...
If writing plugins for the v1.x.x branch what documentation should I use to write updated code ?
EDIT:
I guess this is a better start: https://github.com/NodeBB/nodebb-plugin-quickstartmodule.exports is a node.js thing right. Is it obsolete to use this? Should I only use plugin.load ?
-
Yes, you always need a
module.exports
orexports
, otherwise, NodeBB will not see your hooks.You can see at the end quick-start adds
module.exports = plugin
FYI, you can shorten
var plugin = {} plugin.load = function () { ... } plugin.stuff = function () { ... } module.exports = plugin
to just
exports.load = function () { ... } exports.stuff = function () { ... }
I find this syntax more convenient depending on the plugin complexity.
Copyright © 2024 NodeBB | Contributors