npm.io
0.0.2 • Published 6 years ago

@whalecloud/cms-plugins

Licence
MIT
Version
0.0.2
Deps
1
Size
7 kB
Vulns
0
Weekly
0

Install

npm install --save @whalecloud/cms-plugins

Or if you prefer yarn:

yarn add @whalecloud/cms-plugins

Usage

Adding a plugin
import { registerPlugins } from "@whalecloud/cms-plugins";

// Add a plugin
registerPlugins({
    name: "my-plugin-demo",
    type: "basic-demo",
    render: () => "Hi!"
});

registerPlugins({
    name: "my-plugin-demo2",
    type: "basic-demo",
    render: () => "Hello!"
});
Getting a single plugin by name
// anywhere in your app
import { getPlugin } from "@whalecloud/cms-plugins";

const plugin = getPlugin("my-plugin-demo");
plugin.render();
Getting plugins by type
// anywhere in your app
import { getPlugins } from "@whalecloud/cms-plugins";

const plugins = getPlugins("basic-demo");
<!-- const plugins = getPlugins(); get all plugins-->
plugins.forEach(plugin => {
    plugin.render();
});
Removing a plugin
// anywhere in your app
import { unregisterPlugin } from "@whalecloud/cms-plugins";

unregisterPlugin("my-plugin-demo");