This repository has been archived by the owner on Oct 13, 2018. It is now read-only.
forked from bbatsov/prelude
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hakyll.el
73 lines (61 loc) · 2.27 KB
/
hakyll.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;;; hakyll.el --- Convenience functions for working with Hakyll.
;;
;;; Commentary:
;; Convenience functions for working with Hakyll.
;;; Code:
(defvar hakyll-site-location "~/Sites/hblog/"
"The location of the Hakyll files.")
(defun hakyll-new-post (title tags)
"Create a new Hakyll post for today with TITLE and TAGS."
(interactive "sTitle: \nsTags: ")
(let ((file-name (hakyll-file-name-with-date title)))
(set-buffer (get-buffer-create file-name))
(insert
(format "---\ntitle: %s\ntags: %s\ndescription: \n---\n\n"
title
(downcase tags)))
(write-file
(expand-file-name file-name (concat hakyll-site-location "posts")))
(switch-to-buffer file-name)))
(defun hakyll-new-talk (title)
"Create a new Hakyll talk for today with TITLE."
(interactive "sTitle: ")
(let ((file-name (hakyll-file-name-with-date title)))
(set-buffer (get-buffer-create file-name))
(insert
(format "---\ntitle: %s\ndescription: \n---\n\n" title))
(write-file
(expand-file-name file-name (concat hakyll-site-location "talks")))
(switch-to-buffer file-name)))
(defun hakyll-new-note (title)
"Create a new Note with TITLE."
(interactive "sTitle: ")
(let ((file-name (hakyll-file-name title)))
(set-buffer (get-buffer-create file-name))
(insert (format "---\ntitle: %s\ndescription: \n---\n\n" title))
(write-file
(expand-file-name file-name (concat hakyll-site-location "notes")))
(switch-to-buffer file-name)))
(defun hakyll-new-source (title)
"Create a new Source post with TITLE."
(interactive "sTitle: ")
(let ((file-name (hakyll-file-name title)))
(set-buffer (get-buffer-create file-name))
(insert (format "---\ntitle: %s\ndescription: \n---\n\n" title))
(write-file
(expand-file-name file-name (concat hakyll-site-location "source")))
(switch-to-buffer file-name)))
(defun hakyll-file-name-with-date (title)
"Return a file name based on TITLE for the post."
(concat
(format-time-string "%Y-%m-%d")
"-"
(replace-regexp-in-string " " "-" (downcase title))
".markdown"))
(defun hakyll-file-name (title)
"Return a file name based on TITLE for the note."
(concat
(replace-regexp-in-string " " "-" (downcase title))
".markdown"))
(provide 'hakyll)
;;; hakyll.el ends here