doc: small adjustments

Massimo Melina committed Dec 7, 2024 at 12:35 UTC 86b86ae4d138c907065476d1b8906e2d82fbd606
1 file changed +6 -6
dev-plugins.md
+6 -6
@@ -25,9 +25,9 @@ exports.description = "I'm a nice plugin"
25 The set of things exported goes by the name "exported object".
26 A plugin can define an `init` function like this:
27 ```js
28 -exports.init = api => ({
29 - frontend_css: 'mystyle.css'
30 -})
28 +exports.init = function(api) {
29 + return { frontend_css: 'mystyle.css' }
30 +}
31 ```
32
33 The init function is called by HFS when the module is loaded and should return an object with more things to
@@ -37,9 +37,8 @@ Since it's a basic example, you could have simply defined it like this:
37 exports.frontend_css = 'mystyle.css'
38 ```
39 but in more complex cases you'll need go through the `init`.
40 -Thus, you can decide to return things in the `init` function, or directly in the `exports`.
40 If you need to access the api you must use `init`, since that's the only place where it is found, otherwise you
42 -can go directly with `exports`. The parameter `api` of the init is an object containing useful things [we'll see later](#api-object).
41 +can just use `exports`. The parameter `api` of the init is an object containing useful things [we'll see later](#api-object).
42
43 Let's first look at the things you can export:
44
@@ -81,7 +80,8 @@ All the following properties are optional unless otherwise specified.
80 WARNING: All the properties above are a bit special and must go in `exports` only (thus, not returned in `init`) and the syntax
81 used must be strictly JSON (thus, no single quotes, only double quotes for strings and objects), and must fit one line.
82
84 -- `init` described in the previous section.
83 +- `init: (api: object) => void | object` described in the previous section. If an object is returned,
84 + it will be merged with other "exported" properties described in this section, so you can return `{ unload }` for example.
85 - `frontend_css: string | string[]` path to one or more css files that you want the frontend to load. These are to be placed in the `public` folder (refer below).
86 You can also include external files, by entering a full URL. Multiple files can be specified as `['file1.css', 'file2.css']`.
87 - `frontend_js: string | string[]` path to one or more js files that you want the frontend to load. These are to be placed in the `public` folder (refer below).