Skip to content

Commit

Permalink
Fixed date formatting in userinput
Browse files Browse the repository at this point in the history
  • Loading branch information
voiceinthedark committed Aug 4, 2023
1 parent cfce2d5 commit 78a0843
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ The extension will search for a file called `markdown-blog.yaml` and will parse
### [0.5.1] 2023-08-04
- Fixed issue with userinput containing spaces
- Fixed issue with user input not ending with a `.md`

### [0.5.2] 2023-08-04
- Fixed datetime formatting
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ It can be used with my blog application or as a standalone extension to quickly
`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`

> user prompt accepts a file name of markdown type. If no extension is provided it will be assumed to be markdown and added automatically.
> Prefered file name format is `a-title-of-your-article.md` or `a-title-of-your-article`, if filename is not sluggified it will be sluggified automatically.
> As an example a filename of `a new article` will become `a-new-article.md` automatically.
### (optional) using external yaml configuration
In order to use an external yaml configuration file, you can add a **`markdown-blog.yaml`** file to the root of your project and then use the following command:
`Markdown Blog: Create File`.
Expand Down Expand Up @@ -47,6 +51,9 @@ Initial release of the extension
- Fixed issue with userinput containing spaces
- Fixed issue with user input not ending with a `.md`

### 0.5.2
- Fixed date time formatting


## Future plans

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"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.5.1",
"version": "0.5.2",
"publisher": "voiceinthedark",
"license": "MIT",
"icon": "voiceinthedark.png",
Expand Down
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class App {
// if the file already exists, ask the user if they want to overwrite it

const originalFilename = fileName;
// prefixes filename with the current date
fileName = `${new Date().getFullYear()}-${new Date().getMonth()}-${new Date().getDate()}-${fileName}`;
// prefixes filename with the current date and format month and day
fileName = `${new Date().getFullYear()}-${(new Date().getMonth() + 1).toString().padStart(2, '0')}-${(new Date().getDate()).toString().padStart(2, '0')}-${fileName}`;

const filePath = path.join(currentDirectory, fileName);

Expand Down

0 comments on commit 78a0843

Please sign in to comment.