Skip to content

Commit

Permalink
Added Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
voiceinthedark committed Aug 4, 2023
1 parent 617f1de commit 227a455
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

All notable changes to the "markdown-create-file" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]

- Initial release
- Initial release

## [0.5.0] 2023-08-04
- Added Yaml front-matter config file parsing
The extension will search for a file called `markdown-blog.yaml` and will parse the front-matter from it. The file needs to be in a correct yaml format.

26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ 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`

### (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`.

#### Yaml front-matter config example

The markdown-blog.yaml file should look like this:
```yaml
title: How To Send data from a Vue Page to a persistent Layout
published_at: 2023-07-30T00:39:00+03:00
updated_at: 2023-08-02T22:56:00+03:00
type: article
description: How to send data from a vue page to a persistent layout in Laravel + inertiajs
link: /2023/2023-07-30-how-to-send-data-from-page-to-layout
image: /images/2023-07-31-04-22-45.png
tags: [vue, inertia, laravel, php, blog, layout]
```
The `published_at` and `updated_at` fields can be left empty since they will be automatically generated.
The title and link will also be automatically generated according to user input.

## Installation
To install an extension, run the following command:
`code --install-extension markdown-blog-extension-0.4.0.vsix`
Expand All @@ -19,10 +39,14 @@ or download from Visual studio marketplace: [Marketplace](https://marketplace.vi

Initial release of the extension

### 0.5.0
- Added Yaml front-matter config file parsing.
The extension will search for a file called `markdown-blog.yaml` and will parse the front-matter from it. The file needs to be in a correct yaml format.


## Future plans

- [ ] Add external yaml configuration
- [x] Add external yaml configuration
- [ ] Update Yaml front-matter on save

---
Expand Down
8 changes: 8 additions & 0 deletions markdown-blog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
title: How To Send data from a Vue Page to a persistent Layout
published_at: 2023-07-30T00:39:00+03:00
updated_at: 2023-08-02T22:56:00+03:00
type: article
description: How to send data from a vue page to a persistent layout in Laravel + inertiajs
link: /2023/2023-07-30-how-to-send-data-from-page-to-layout
image: /images/2023-07-31-04-22-45.png
tags: [vue, inertia, laravel, php, blog, layout]
22 changes: 14 additions & 8 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const vscode = require('vscode');
const path = require('path');
const fs = require('fs');
const yaml = require('js-yaml');
const { title } = require('process');

class App {
/**
Expand Down Expand Up @@ -52,17 +53,22 @@ class App {
const filePath = path.join(currentDirectory, fileName);

let data;
if(this.readYmlFile(this.getConfigFilePath())) {
if (this.readYmlFile(this.getConfigFilePath())) {
data = this.readYmlFile(this.getConfigFilePath());
data['published_at'] = new Date().toISOString();
data['updated_at'] = new Date().toISOString();
// convert filename to title, replace underscores and dashes with spaces
data['title'] = originalFilename.split('.')[0].replace(/_/g, ' ').replace(/-/g, ' ');
data['link'] = `/${new Date().getFullYear()}/${originalFilename.split('.')[0]}`;
data = `---\n${yaml.dump(data)}---`;
} else {
// fill the file with a YAML frontmatter
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---`;
}


// fill the file with a YAML frontmatter
/* 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, yaml.dump(data), (err) => {
fs.writeFile(filePath, data, (err) => {
if (err) {
console.log(err);
}
Expand Down

0 comments on commit 227a455

Please sign in to comment.