Last active
April 18, 2021 22:53
-
-
Save dealingwith/baed8abe1ce1413cb7b897c32c4aa74d to your computer and use it in GitHub Desktop.
Create a new Jekyll post with Script Kit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let {format} = await npm('date-fns') | |
let title = await arg('Name of post') | |
let file_title = title.toLowerCase().replaceAll(' ', '-') | |
let posts_path = '/Users/danielmiller/code/daniel-industries/_posts/' | |
let date = new Date() | |
let date_for_path = format(date, 'yyyy-MM-dd') | |
let date_for_yml = format(date, 'yyyy-MM-dd hh:mm:ss z') | |
let file_path = posts_path + date_for_path + '-' + file_title + '.markdown' | |
let file_contents = `--- | |
layout: post | |
title: "${ title }" | |
excerpt: | |
date: ${ date_for_yml } | |
categories: | |
--- | |
` | |
writeFile(file_path, file_contents) | |
exec(`code ${file_path} --new-window`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replaces my old
new_post
Rake task, with the added benefit of opening the post in a dedicated VS Code window.