mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-03-28 17:42:40 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50e62b2925 | ||
|
|
c41e7cf5fc |
@@ -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
|
||||
|
||||
@@ -28,12 +28,14 @@ Once a custom action has been configured, it will appear on the Front Matter pan
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||
6141
package-lock.json
generated
6141
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
"displayName": "Front Matter",
|
||||
"description": "Simplifies working with front matter of your articles. Useful extension when you are using a static site generator like: Hugo, Jekyll, Hexo, NextJs, Gatsby, and many more...",
|
||||
"icon": "assets/front-matter.png",
|
||||
"version": "1.15.1",
|
||||
"version": "1.16.0",
|
||||
"preview": false,
|
||||
"publisher": "eliostruyf",
|
||||
"galleryBanner": {
|
||||
@@ -240,6 +240,7 @@
|
||||
"@types/react-dom": "17.0.0",
|
||||
"@types/vscode": "1.51.0",
|
||||
"date-fns": "2.0.1",
|
||||
"downshift": "6.0.6",
|
||||
"glob": "7.1.6",
|
||||
"gray-matter": "4.0.2",
|
||||
"html-loader": "1.3.2",
|
||||
@@ -250,7 +251,6 @@
|
||||
"tslint": "6.1.3",
|
||||
"typescript": "4.0.2",
|
||||
"webpack": "4.44.2",
|
||||
"webpack-cli": "3.3.12",
|
||||
"downshift": "6.0.6"
|
||||
"webpack-cli": "3.3.12"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,16 +175,19 @@ export class ExplorerView implements WebviewViewProvider, Disposable {
|
||||
const config = workspace.getConfiguration(CONFIG_KEY);
|
||||
const scripts: CustomScript[] | undefined = config.get(SETTING_CUSTOM_SCRIPTS);
|
||||
|
||||
|
||||
if (msg?.data?.title && msg?.data?.script && scripts) {
|
||||
const customScript = scripts.find((s: CustomScript) => s.title === msg.data.title);
|
||||
if (customScript?.script && customScript?.title) {
|
||||
const editor = window.activeTextEditor;
|
||||
if (!editor) return;
|
||||
|
||||
const article = ArticleHelper.getFrontMatter(editor);
|
||||
|
||||
const wsFolders = workspace.workspaceFolders;
|
||||
if (wsFolders && wsFolders.length > 0) {
|
||||
const wsPath = wsFolders[0].uri.fsPath;
|
||||
|
||||
exec(`${customScript.nodeBin || "node"} ${path.join(wsPath, msg.data.script)} "${wsPath}" "${editor?.document.uri.fsPath}"`, (error, stdout) => {
|
||||
exec(`${customScript.nodeBin || "node"} ${path.join(wsPath, msg.data.script)} "${wsPath}" "${editor?.document.uri.fsPath}" "${JSON.stringify(article?.data)}"`, (error, stdout) => {
|
||||
if (error) {
|
||||
window.showErrorMessage(`${msg?.data?.title}: ${error.message}`);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user