Skip to content

Instantly share code, notes, and snippets.

@tpanum
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tpanum/f1bcd76cfdc6d3f3b28a to your computer and use it in GitHub Desktop.
Save tpanum/f1bcd76cfdc6d3f3b28a to your computer and use it in GitHub Desktop.
Create Jekyll post from Emacs
(defun tpanum/create-jekyll-post
(title)
"Creates a new buffer and file for a blog post"
(interactive "sTitle of blog post: ")
(let
((filename
(concat
(format-time-string "%Y-%m-%d-")
(replace-regexp-in-string " " "-"
(downcase
(replace-regexp-in-string "[^0-9a-zA-Z ]" "" title))))))
(switch-to-buffer
(generate-new-buffer filename))
(insert
(concat
(mapconcat 'identity
'("---" "layout: post")
"\n")
"\n" "title: '" title "'\n" "date: '"
(format-time-string "%Y-%m-%d %H:%M:%S %z")
"'\n" "---\n"))
(if
(boundp 'blog-home)
(write-file
(concat blog-home "/_posts/" filename ".markdown")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment