npm.io
0.0.7 • Published 6 years ago

cms-plugin-utilst

Licence
MIT
Version
0.0.7
Deps
1
Size
10 kB
Vulns
0
Weekly
0

Install

npm install --save cms-plugin-utilst

Or if you prefer yarn:

yarn add cms-plugin-utilst

Usage

Adding a plugin
import { registerPlugins } from "cms-plugin-utilst";

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

registerPlugins({
    name: "my-second-plugin",
    type: "say-hi",
    render: () => "Yo!"
});
Getting a single plugin by name
// anywhere in your app
import { getPlugin } from "cms-plugin-utilst";

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

const plugins = getPlugins("say-hi");
plugins.forEach(plugin => {
    plugin.render();
});
Removing a plugin
// anywhere in your app
import { unregisterPlugin } from "cms-plugin-utilst";

unregisterPlugin("my-plugin");
renderPlugin
// anywhere in your app
import { renderPlugin } from "cms-plugin-utilst";

<div>
  {renderPlugin('my-plugin', {})}
</div>
renderPlugins
// anywhere in your app
import { renderPlugins } from "cms-plugin-utilst";

<div>
  {renderPlugins('say-hi', {})}
</div>