nodewrite-core-plugins
v1.0.18
Published
core plugins for nodewrite
Downloads
3
Readme
Core Plugins
Handles the registration of installed plugins.
Installation
npm install nodewrite-core-plugins --save
This is a core package and is installed by default.
Usage
The file structure for a plugin:
.
├── /config
| └── default.yml
├── /assets
├── /models
├── /public
├── /test
├── /views
| ├── /helpers
| ├── /layouts
| └── /partials
├── README.md [required]
├── icon.png
├── index.js [required]
└── package.json [required]
Helper Methods
server.getPluginRegistry(callback)
server.getPluginReadMe(name, callback)
server.getPlugin(name, callback)
server.getPluginRegistry(callback)
Returns an array of installed plugin objects.
callback
- method to call with a signature offunction(error, plugins)
.error
- any error encountered while trying to read.plugins
- registry array of plugins.
server.getPluginRegistry((error, plugins) => {
if (error) throw error;
const registry = plugins;
});
Resulting registry array:
[
{
package: {
name: "nodewrite-plugin-stripe",
version: "1.0.0",
description: "stripe plugin for nodewrite",
// package.json ..
},
short: {
name: "plugin-stripe",
url: "/plugins/stripe",
}
},
// etc ...
]
server.getPluginReadMe(name, callback)
Returns contents of a plugin's README.md
file.
name
- plugin name of package to read.callback
- method to call with a signature offunction(error, source)
.error
- any error encountered while trying to read.source
- contents of pluginREADME.md
file.
server.getPluginReadMe('nodewrite-plugin-stripe', (error, source) => {
if (error) throw error;
const content = source;
});
Resulting content is the raw markdown:
## Stripe Plugin
etc ...
server.getPlugin(name, callback)
Returns a single plugin object from the installed plugins registry.
name
- plugin name of package to read.callback
- method to call with a signature offunction(error, plugin)
.error
- any error encountered while trying to read.plugin
- registry object for plugin.
server.getPlugin('nodewrite-plugin-stripe', (error, plugin) => {
if (error) throw error;
const registry = plugin;
});
Resulting plugin registry object:
{
package: {
name: "nodewrite-plugin-stripe",
version: "1.0.0",
description: "stripe plugin for nodewrite",
// package.json ..
},
short: {
name: "plugin-stripe",
url: "/plugins/stripe",
}
}
Getting Help
Open an issue on this repository!