diff --git a/config.el b/config.el index 0577962..ac74fcc 100644 --- a/config.el +++ b/config.el @@ -449,6 +449,7 @@ only the description" (require 'qwan-blog) + ;; org-roam v1 port to v2, insert node without opening buffer (map! :leader diff --git a/qwan/qwan-blog.el b/qwan/qwan-blog.el index 5f94e06..aaf7fad 100644 --- a/qwan/qwan-blog.el +++ b/qwan/qwan-blog.el @@ -5,7 +5,7 @@ (defun qwan/copy-filename () - "Push the file name of the currently visited buffer to the kill ring." + "Push the file name of the currently visited buffer to the kill ring. Useful for markdown links" (interactive) (unless buffer-file-name (error "The current buffer doesn't visit a file")) @@ -13,3 +13,17 @@ (kill-new buffer-file-name) (message "Copied %s" buffer-file-name)) +(defun qwan/publish-draft () + "Publish this in the _posts folder" + (interactive) + (let* ((dest-dir "../_posts") + (current-file (buffer-file-name)) + (blogpost-name (file-name-nondirectory current-file)) + (current-date (format-time-string "%Y-%m-%d")) + (new-filename (concat current-date "-" blogpost-name)) + (source-path current-file) + (dest-path (concat dest-dir "/" new-filename))) + (rename-file source-path dest-path) + (set-visited-file-name dest-path) + (set-buffer-modified-p nil) + (message "Successfully moved %s to %s" source-path dest-path)))