Last active
August 29, 2015 14:07
-
-
Save tpanum/f1bcd76cfdc6d3f3b28a to your computer and use it in GitHub Desktop.
Create Jekyll post from Emacs
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
(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