0.0.7 • Published 4 years ago

cms-plugin-utilst v0.0.7

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

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>