diff --git a/README.md b/README.md index a93da0e..94aab3a 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,31 @@ -# markdown-create-file README +# Markdown Blog Companion Extension -This is the README for your extension "markdown-create-file". After writing up a brief description, we recommend including the following sections. +A markdown extension which is a companion to my [markdown-blog](https://github.com/voiceinthedark/markdown-blog). +A new markdown file will be created in the current directory with the required Yaml front-matter required to display the blog's articles. -## Features +## Usage -Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. +`ctrl + shift + p` to open vscode command palette and search for `Markdown Blog: Create File` +Or inside the active text editor press `ctrl + shift + c` -For example if there is an image subfolder under your extension project workspace: +## Installation -\!\[feature X\]\(images/feature-x.png\) - -> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. - -## Requirements - -If you have any requirements or dependencies, add a section describing those and how to install and configure them. - -## Extension Settings - -Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. - -For example: - -This extension contributes the following settings: - -* `myExtension.enable`: Enable/disable this extension. -* `myExtension.thing`: Set to `blah` to do something. ## Known Issues Calling out known issues can help limit users opening duplicate issues against your extension. ## Release Notes +### 0.4.0 -Users appreciate release notes as you update your extension. - -### 1.0.0 +Initial release of the extension -Initial release of ... - -### 1.0.1 - -Fixed issue #. - -### 1.1.0 - -Added features X, Y, and Z. --- - -## Working with Markdown - -You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: - -* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux) -* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux) -* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets - ## For more information -* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) -* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) +- [GitHub repo](https://github.com/voiceinthedark/markdown-blog-extension) +- [Markdown Blog](https://github.com/voiceinthedark/markdown-blog) + **Enjoy!** diff --git a/package.json b/package.json index 22af4b7..a935d9d 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "markdown-create-file", - "displayName": "markdown-create-file", + "name": "markdown-blog-extension", + "displayName": "Markdown Blog Extension", "description": "A companion extension to my markdown-blog which will create a new file in the current directory complete with the required Yaml scaffolding", - "version": "0.0.1", + "version": "0.4.0", "engines": { "vscode": "^1.80.0" }, @@ -10,11 +10,17 @@ "Other", "Snippets" ], "activationEvents": [], - "main": "./extension.js", + "main": "./src/extension.js", "contributes": { "commands": [{ - "command": "markdown-create-file.createFile", - "title": "Markdown create file: Create File" + "command": "markdown-blog-extension.createFile", + "title": "Markdown Blog: Create File" + }], + "keybindings": [{ + "command": "markdown-blog-extension.createFile", + "key": "ctrl+shift+c", + "mac": "cmd+shift+c", + "when": "editorTextFocus" }] }, "scripts": { diff --git a/app.js b/src/app.js similarity index 97% rename from app.js rename to src/app.js index 148be67..2500c39 100644 --- a/app.js +++ b/src/app.js @@ -34,7 +34,7 @@ class App{ const filePath = path.join(currentDirectory, fileName); // fill the file with a YAML frontmatter - const data = `---\ntitle: ${originalFilename.split('.')[0]}\npublished_at: ${new Date().toISOString()}\nupdated_at: ${new Date().toISOString()}\ntype: article\ndescription: Enter description here\nlink: /${new Date().getFullYear()}/${originalFilename}\nimage: image.png\ntags: [tag1,tag2]\n---`; + const data = `---\ntitle: ${originalFilename.split('.')[0]}\npublished_at: ${new Date().toISOString()}\nupdated_at: ${new Date().toISOString()}\ntype: article\ndescription: Enter description here\nlink: /${new Date().getFullYear()}/${originalFilename}\nimage: images/image.png\ntags: [tag1,tag2]\n---`; fs.writeFile(filePath, data.trim(), err => { if(err) { diff --git a/extension.js b/src/extension.js similarity index 90% rename from extension.js rename to src/extension.js index 2dcf589..cbb8b08 100644 --- a/extension.js +++ b/src/extension.js @@ -18,7 +18,7 @@ function activate(context) { // The command has been defined in the package.json file // Now provide the implementation of the command with registerCommand // The commandId parameter must match the command field in package.json - let disposable = vscode.commands.registerCommand('markdown-create-file.createFile', function () { + let disposable = vscode.commands.registerCommand('markdown-blog-extension.createFile', function () { // The code you place here will be executed every time your command is executed let currentDirectory = app.getCurrentDirectory(); @@ -40,6 +40,10 @@ function activate(context) { }).then(function (fileName) { // Create file in current directory let filepath = app.createFile(currentDirectory, fileName); + if(!filepath) { + app.showErrorMessage('Failed to create file'); + return; + } // get the last created file and show it vscode.window.showTextDocument(vscode.Uri.file(filepath)); })