Added sample for custom actions

This commit is contained in:
Elio Struyf
2021-07-07 12:36:48 +02:00
parent 13cb8fcff5
commit 59c962d8fc
2 changed files with 20 additions and 4 deletions

View File

@@ -32,12 +32,18 @@ The current workspace-, file-path, and front matter data will be passed as an ar
```javascript ```javascript
const arguments = process.argv; const arguments = process.argv;
const workspaceArg = arguments[2];
const fileArg = arguments[3]; if (arguments && arguments.length > 0) {
const dataArg = arguments[4]; const workspaceArg = arguments[2]; // The workspace path
const data = dataArg && typeof dataArg === "string" ? JSON.parse(dataArg) : null; const fileArg = arguments[3]; // The file path
const frontMatterArg = arguments[4]; // Front matter data
console.log(`The content returned for your notification.`);
}
``` ```
> A sample file can be found here: ![script-sample.js](./sample/script-sample.js)
The output of the script will be passed as a notification, and it allows you to copy the output. The output of the script will be passed as a notification, and it allows you to copy the output.
![](./assets/custom-action-notification.png) ![](./assets/custom-action-notification.png)

10
sample/script-sample.js Normal file
View File

@@ -0,0 +1,10 @@
const arguments = process.argv;
if (arguments && arguments.length > 0) {
const workspaceArg = arguments[2]; // The workspace path
const fileArg = arguments[3]; // The file path
const frontMatterArg = arguments[4]; // Front matter data
console.log(`The content returned for your notification.`);
}