0.0.2 • Published 4 years ago

@whalecloud/cms-plugins v0.0.2

Weekly downloads
12
License
MIT
Repository
-
Last release
4 years ago

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");