Skip to content

Commit

Permalink
Added front matter to custom script arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed May 4, 2021
1 parent 232c3ff commit c41e7cf
Show file tree
Hide file tree
Showing 5 changed files with 6,152 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [1.16.0] - 2020-05-04

- Add all front matter properties as an argument for custom scripts

## [1.15.1] - 2020-05-04

- Add the ability to specify a custom Node path
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ Once a custom action has been configured, it will appear on the Front Matter pan

![](./assets/custom-actions.png)

The current workspace- and file-path will be passed as an argument. In your script fetch these arguments as follows:
The current workspace-, file-path, and front matter data will be passed as an argument. In your script fetch these arguments as follows:

```javascript
const arguments = process.argv;
const workspaceArg = arguments[2];
const fileArg = arguments[3];
const dataArg = arguments[4];
const data = dataArg && typeof dataArg === "string" ? JSON.parse(dataArg) : null;
```

The output of the script will be passed as a notification, and it allows you to copy the output.
Expand Down
Loading

0 comments on commit c41e7cf

Please sign in to comment.