Last active
June 1, 2024 13:51
-
-
Save alexispurslane/73980e92173d5cb85f2b644734c265ba to your computer and use it in GitHub Desktop.
Use org mode and emacs to directly generate your blog, no external programs needed!
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 optional/blog-layer () | |
"Blog writing is one of the most common writing tasks there | |
is. With the existing `task/writing-layer' you should have all | |
you need to write blog entries, but in case you want to fully | |
generate and manage your entire blog from inside Emacs, then this | |
layer is for you. | |
Loads: | |
- `async`: so you can run the blog build in the background. | |
- `org-static-blog': A beautifully simple SSG for org." | |
(use-package async | |
:commands (async-start async-start-process)) | |
(use-package org-static-blog | |
:commands (org-static-blog-publish org-static-blog-publish-file org-static-blog-mode) | |
:config | |
(add-hook 'org-mode-hook | |
(lambda () | |
(+core--internal-local-map! | |
"p" #'org-static-blog-publish-async)))) | |
(define-minor-mode org-static-blog-watch-mode | |
"Re-run `org-static-blog-publish-async' whenever the current file is saved." | |
:init-value nil | |
:lighter " Org-Static-Blog-Watch" | |
(add-hook 'after-save-hook #'org-static-blog-publish-async nil t)) | |
(defun org-static-blog-publish-async () | |
(interactive) | |
(async-start | |
`(lambda () | |
(let ((start-time (current-time))) | |
(setq load-path ',load-path) | |
(require 'org-static-blog) | |
transfer variables without having to load this entire init.el file again | |
,@(cl-loop for x in (cl-remove 'custom-group (custom-group-members group nil) | |
:key #'cadr) | |
for variable = (car x) | |
for value = (symbol-value variable) | |
collect `(setq ,variable ,value)) | |
(org-static-blog-publish) | |
(format "%.2f" (float-time (time-since start-time))))) | |
(lambda (publish-time) | |
(message (format "Finished publishing blog after %s seconds" publish-time)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment