-
-
Notifications
You must be signed in to change notification settings - Fork 123
Sample Plugin
Marc Espín Sanz edited this page Jun 24, 2020
·
12 revisions
Note: Plugins in v2.X works slight different compared to v1.X.
Create the project folder in your .graviton2/plugins.
Create the plugin folder, you can name it as you wish.
mkdir SamplePluginGo inside it.
cd SamplePluginNow, let's create our package.json ( You can use npm init if you wish.)
| Property | Definition |
|---|---|
| name | Plugin's name |
| id | Technical name (no spaces) |
| main | Location of your main file |
Example:
{
"name": "SamplePlugin",
"id": "sample-plugin",
"main" :"main.js",
}Create the main file in the root folder.
touch main.jsPaste this code in the main.js:
function entry(API){
new API.Notification({
title: 'A cool notification!',
content: 'Some content :)'
})
}
module.exports = { entry }What is this code doing?
- We have declared our entry function, this will be executed when Graviton loads the plugin.
- The entry function has only one argument, it's the API, it's an object containing all the different components and methods you can use in your plugin.
- As you can see, it's creating a Notification, it passes as an argument, an object with two properties, the title and the content.
- And finally, you export the entry function so Graviton can recognize and execute it.
Documentation
Tutorials
Contributing
About