Skip to content

Instantly share code, notes, and snippets.

Last active Apr 18, 2021
What would you like to do?
Create a new Jekyll post with Script Kit
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 }"
date: ${ date_for_yml }
writeFile(file_path, file_contents)
exec(`code ${file_path} --new-window`)

This comment has been minimized.

Copy link
Owner Author

@dealingwith dealingwith commented Apr 17, 2021

Replaces my old new_post Rake task, with the added benefit of opening the post in a dedicated VS Code window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment