@@ -3,7 +3,7 @@ title: Custom actions
3
3
slug : custom-actions
4
4
description : null
5
5
date : 2021-08-30T16:13:00.546Z
6
- lastmod : 2023-12-07T16:37:05.124Z
6
+ lastmod : 2024-01-31T12:48:37.504Z
7
7
weight : 500
8
8
---
9
9
@@ -116,12 +116,12 @@ When you do not want to use the `@frontmatter/extensibility` package, you can cr
116
116
follows:
117
117
118
118
``` javascript
119
- const arguments = process .argv ;
119
+ const args = process .argv ;
120
120
121
- if (arguments && arguments .length > 0 ) {
122
- const workspaceArg = arguments [2 ]; // The workspace path
123
- const fileArg = arguments [3 ]; // The file path
124
- const frontMatterArg = arguments [4 ]; // Front matter data
121
+ if (args && args .length > 0 ) {
122
+ const workspaceArg = args [2 ]; // The workspace path
123
+ const fileArg = args [3 ]; // The file path
124
+ const frontMatterArg = args [4 ]; // Front matter data
125
125
126
126
console .log (` The content returned for your notification.` );
127
127
}
@@ -130,9 +130,9 @@ if (arguments && arguments.length > 0) {
130
130
The current workspace-, file-path, and front matter data will be passed as a arguments. Like you can
131
131
see in the above sample script, you can fetch these argument values as follows:
132
132
133
- - ` arguments [2]` : The workspace path
134
- - ` arguments [3]` : The file path (Markdown file)
135
- - ` arguments [4]` : The front matter data as object
133
+ - ` args [2]` : The workspace path
134
+ - ` args [3]` : The file path (Markdown file)
135
+ - ` args [4]` : The front matter data as object
136
136
137
137
### Creating a script with the extensibility package
138
138
@@ -272,8 +272,8 @@ Here is a sample on how you can define a media script:
272
272
273
273
The script will provide you the following arguments:
274
274
275
- - ` arguments [2]` : The workspace path
276
- - ` arguments [3]` : The file or folder path. This depends on the type of script.
275
+ - ` args [2]` : The workspace path
276
+ - ` args [3]` : The file or folder path. This depends on the type of script.
277
277
278
278
When using the ` @frontmatter/extensibility ` package, you can get the arguments as follows:
279
279
@@ -383,15 +383,15 @@ print(f'frontMatterArg: {sys.argv[3]}')
383
383
``` javascript
384
384
const path = require (" path" );
385
385
386
- const arguments = process .argv ;
386
+ const args = process .argv ;
387
387
388
388
(async () => {
389
- if (arguments && arguments .length > 0 ) {
389
+ if (args && args .length > 0 ) {
390
390
const imagemin = (await import (" imagemin" )).default ;
391
391
const imageminJpegtran = (await import (" imagemin-jpegtran" )).default ;
392
392
const imageminPngquant = (await import (" imagemin-pngquant" )).default ;
393
393
394
- const fileArg = arguments [3 ]; // The file path
394
+ const fileArg = args [3 ]; // The file path
395
395
396
396
await imagemin ([fileArg], {
397
397
destination: path .dirname (fileArg),
@@ -413,16 +413,16 @@ const arguments = process.argv;
413
413
``` javascript
414
414
const path = require (" path" );
415
415
416
- const arguments = process .argv ;
416
+ const args = process .argv ;
417
417
418
418
(async () => {
419
- if (arguments && arguments .length > 0 ) {
419
+ if (args && args .length > 0 ) {
420
420
const imagemin = (await import (" imagemin" )).default ;
421
421
const imageminJpegtran = (await import (" imagemin-jpegtran" )).default ;
422
422
const imageminPngquant = (await import (" imagemin-pngquant" )).default ;
423
423
424
- const workspaceArg = arguments [2 ]; // The workspace path
425
- const folderArg = arguments [3 ]; // The folder path
424
+ const workspaceArg = args [2 ]; // The workspace path
425
+ const folderArg = args [3 ]; // The folder path
426
426
427
427
const files = await imagemin ([path .join (folderArg, " *.{jpg,png}" )], {
428
428
destination: folderArg,
0 commit comments