From d7b549a94c89edba77c4a750faa210d4a53e1c2e Mon Sep 17 00:00:00 2001 From: Emmet Date: Mon, 20 Nov 2023 17:16:15 -0600 Subject: [PATCH] Convenience functions for my new jekyll blog --- user/app/doom-emacs/config.el | 17 +++++++++++++++++ user/app/doom-emacs/doom.org | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/user/app/doom-emacs/config.el b/user/app/doom-emacs/config.el index ff2a743..9a65aed 100644 --- a/user/app/doom-emacs/config.el +++ b/user/app/doom-emacs/config.el @@ -529,6 +529,23 @@ same directory as the org-buffer and insert a link to this file." (add-hook 'org-mode-hook #'org-transclusion-mode) +(defun org-jekyll-new-post () + (interactive) + (setq new-blog-post-title (read-from-minibuffer "Post name: ")) + (setq new-blog-post-slug (downcase (replace-regexp-in-string "[^[:alpha:][:digit:]_-]" "" (string-replace " " "-" new-blog-post-title)))) + (setq new-blog-post-file (concat (projectile-project-root) "org/_posts/" (format-time-string "%Y-%m-%d") "-" new-blog-post-slug ".org")) + (let ((org-capture-templates + `(("p" "New Jekyll blog post" plain (file new-blog-post-file) + ,(concat "#+title: " new-blog-post-title "\n#+options: toc:nil num:nil\n#+begin_export: html\n---\nlayout: post\ntitle: " new-blog-post-title "\nexcerpt: %?\ntags: \npermalink: " new-blog-post-slug "\n---\n#+end_export\n"))) + )) (org-capture)) +) + +(map! :leader + :prefix ("N") + + :desc "New blog post" + "p" #'org-jekyll-new-post) + ;;;------ Org roam configuration ------;;; (require 'org-roam) (require 'org-roam-dailies) diff --git a/user/app/doom-emacs/doom.org b/user/app/doom-emacs/doom.org index 0d07f89..b3ce5f2 100644 --- a/user/app/doom-emacs/doom.org +++ b/user/app/doom-emacs/doom.org @@ -648,6 +648,26 @@ exit (add-hook 'org-mode-hook #'org-transclusion-mode) #+END_SRC +*** Org Jekyll +#+begin_src emacs-lisp :tangle config.el +(defun org-jekyll-new-post () + (interactive) + (setq new-blog-post-title (read-from-minibuffer "Post name: ")) + (setq new-blog-post-slug (downcase (replace-regexp-in-string "[^[:alpha:][:digit:]_-]" "" (string-replace " " "-" new-blog-post-title)))) + (setq new-blog-post-file (concat (projectile-project-root) "org/_posts/" (format-time-string "%Y-%m-%d") "-" new-blog-post-slug ".org")) + (let ((org-capture-templates + `(("p" "New Jekyll blog post" plain (file new-blog-post-file) + ,(concat "#+title: " new-blog-post-title "\n#+options: toc:nil num:nil\n#+begin_export: html\n---\nlayout: post\ntitle: " new-blog-post-title "\nexcerpt: %?\ntags: \npermalink: " new-blog-post-slug "\n---\n#+end_export\n"))) + )) (org-capture)) +) + +(map! :leader + :prefix ("N") + + :desc "New blog post" + "p" #'org-jekyll-new-post) + +#+end_src ** Org Roam Configuration *** Standard Org Roam Configuration #+BEGIN_SRC emacs-lisp :tangle config.el