This is my first public VSCode extension project, and I welcome any constructive feedback, suggestions, or bug reports. Feel free to create an issue if you encounter any problems or have suggestions for improvement.
Jekyll Helper simplifies the process of managing Jekyll blog posts directly from Visual Studio Code, streamlining tasks like creating drafts, publishing posts, and managing front matter metadata. This project is based on Nor-s/front-matter-gen, itself a fork of Abdillah/vscode-belikejekyll and rohgarg/jekyll-post.
- Added "Title Case" Function: Implemented functionality to convert titles to title case in the front matter.
- Added Draft Button: Introduced a button for creating new drafts.
- Added Publish Button: Created a button for publishing drafts as posts.
- Implemented Filename Uniqueness Checks: Ensured unique filenames by adding numeric suffixes (e.g., '-1').
- Refactored and Sanitized Core Source Code: Improved, extended, and cleaned up the core code.
- Modified Date Filename Pattern and File Extension Configuration: Updated the filename format to include dates and customized file extension handling.
This VSCode extension adds intuitive buttons to simplify the creation, editing, and publishing of Jekyll blog posts and drafts. It enhances the workflow by providing pre-filled "front matter" templates and ensuring unique filenames for posts and drafts.
- New Explorer Context Menu Options:
- New Jekyll Post: Creates a new blog post with front matter.
- New Jekyll Draft: Creates a draft with front matter.
- Publish Jekyll Draft:
- Checking if there are unsaved changes in the draft file before proceeding.
- Adding the current date to both the filename and the front matter.
- Updating the filename based on the title specified in the front matter.
- Moving the file to the _posts directory.
- Automatic Filename Generation:
- Adds the current date in
YYYY-MM-DD
format. - Sanitizes the title by replacing spaces with hyphens and converting it to lowercase.
- Checks for filename uniqueness and adds numeric suffixes if necessary (e.g.,
-1
,-2
).
- Adds the current date in
- Title Case Conversion: Automatically converts the user-provided title into Title Case in the front matter.
- Customizable Templates: Allows the use of custom templates for new posts and drafts. If no template is provided, a built-in default template is used.
This extension has been tested on Visual Studio Code and VSCodium (v1.93). Compatibility with earlier versions may not be guaranteed.
- Manual Installation (VSIX File)
- Download Jekyll Helper VSIX
- In VSCode, press Ctrl+Shift+P (Windows and Linux), type
Extensions: Install from VSIX...
, and select the downloaded.vsix
file. - Alternatively, you can open the Extensions view in VSCode, click on the three-dot menu in the top right, and select
Install from VSIX...
- Jekyll Helper on the VSCode Marketplace
- Alternatively, you can open the Extensions view in VSCode and search for
Jekyll Helper
to install directly from the marketplace.
- Enable the Extension: Set
jekyllhelper.enabled
totrue
in yoursettings.json
file. - Right-click on a Directory: Right-click on a folder in the VSCode Explorer.
- New Jekyll Post: Creates a post with the current date in the filename.
- New Jekyll Draft: Creates a draft with the current date in the filename.
- Select a Template: If you have multiple templates, choose one from the list when prompted.
- Enter a Title: Provide a title when prompted. The extension will use this title for both the front matter and the filename.
- Publish a Draft: When ready to publish, right-click on the draft file and select "Publish Jekyll Draft" to convert it into a post. The extension will automatically add the current date and update the front matter title to match the filename.
To provide a custom template for posts, place your template file in .vscode/jekyll-helper-tmpl/{template-file}
relative to your project’s root directory.
Here's an example of a custom template:
---
layout: post
title: "${title}"
date: ${date}
category: [cat1]
author: User
tags: [tag1, tag2]
description: ""
---
If no custom template is provided, the extension will use the following default template:
---
layout: post
title: "${title}"
date: ${date}
category:
author:
tags: []
description: ""
---
jekyllhelper.enabled
: Enable or disable the extension.jekyllhelper.template.path
: Set the path to the directory containing template files.
- Visual Studio Code (VSCode) or VSCodium: v1.93 or higher
- Node.js: v18.x (tested with v18.16.0)
- NPM: v9.x (tested with v9.5.0) or an alternative Node.js package manager
- vsce (for packaging the extension)
- Install globally with NPM:
npm install -g vsce
- Install globally with NPM:
- Git (optional, but recommended)
- Clone the Git repository
git clone https://gitlab.com/m0x2A/jekyll-helper.git
cd jekyll-helper
- Alternatively, download the source code as a ZIP file from GitLab
- Install dependencies
npm install
- Make changes or compile the extension
- To compile the project:
npm run compile
- To debug the extension in VSCode:
- Press
F5
in VSCode to start debugging
- Press
- To create a VSIX package:
vsce package
- To compile the project:
The TypeScript project is already configured via the tsconfig.json
file, which can be found in the root of the repository.
- Add functions for creating posts, drafts, and publishing drafts as commands in the command palette.
- Improve the Title Case function and add a configuration setting to disable it for non-English titles.
- Restrict buttons to function only within folders specified in the configuration (e.g., _posts, _drafts).
- Refactoring for DRY principle.
Enjoy using Jekyll Helper!