From 3c7a5ac9477d7c7f57ccf29c192343aa19e7cb70 Mon Sep 17 00:00:00 2001 From: Ezinwa Okpoechi Date: Wed, 12 Apr 2017 09:26:16 +0100 Subject: [PATCH] Add plugin settings usage example --- docs/plugins/examples.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/plugins/examples.md b/docs/plugins/examples.md index d6002d42..8273962e 100644 --- a/docs/plugins/examples.md +++ b/docs/plugins/examples.md @@ -141,3 +141,33 @@ module.exports = { fn: plugin }; ``` + +### using `settings` +```js +const plugin = ({ display, settings }) => { + const icon = require('[path-to-icon]/icon.png'); + + display({ + icon: settings.icon ? icon : '', + title: `${settings.username}, you have been around for ${settings.age}`, + subtitle: `Favorite languages: ${settings.languages.join(',')}`, + }) +} + +module.exports = { + fn: plugin, + settings: { + username: { type: 'string' }, + age: { type: 'number', defaultValue: 42 }, + icon: { type: 'bool' }, + languages: { + type: 'option', + description: 'Your favorite programming languages' + options: ['JavaScript', 'Haskell', 'Rust'], + multi: true, + createable: true, + } + } +} + +```