nodewrite-core-plugins

core plugins for nodewrite

Usage no npm install needed!

<script type="module">
  import nodewriteCorePlugins from 'https://cdn.skypack.dev/nodewrite-core-plugins';
</script>

README

Core Plugins

Build Status CodeClimate Coverage Status Dependency Status

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)

Returns an array of installed plugin objects.

  • callback - method to call with a signature of function(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 of function(error, source).
    • error - any error encountered while trying to read.
    • source - contents of plugin README.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 of function(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!