0.0.7 • Published 6 years ago
cms-plugin-utilst v0.0.7
Install
npm install --save cms-plugin-utilstOr if you prefer yarn:
yarn add cms-plugin-utilstUsage
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>