-
-
Notifications
You must be signed in to change notification settings - Fork 126
Sample Plugin
Marc Espín Sanz edited this page May 15, 2020
·
12 revisions
Note: Plugins in v2.X works slight different compared to v1.X.
- Create the project folder in .graviton2/plugins.
mkdir SamplePlugin
cd SamplePlugin
- Now, let's create our package.json ( You can use
npm init
if you wish.)
Property | Definition |
---|---|
name | name of your plugin, it cannot contain spaces |
id | more specific name |
main | refers to the location of your main file |
mainDev | indicates the main file when the plugin is being developed |
mainSrc | indicates the main file in the source code |
It must have at least 2 properties ( just for now ).
- name:
- id:
- main: .
- mainDev:
- mainSrc:
Example:
{
"name": "SamplePlugin",
"id": "sample-plugin",
"main" :"main.js",
"mainSrc": "main.js",
"mainDev": "main.js"
}
- Create the main file in the root folder.
touch main.js
- Paste 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 execute it.
Documentation
Tutorials
Contributing
About