Add hugo rebuild hook

This commit is contained in:
MitchMarq42 2022-11-22 06:42:19 -09:00
parent f01afb0bc3
commit 4a1d9eee4a

View File

@ -648,7 +648,19 @@ See https://emacs.stackexchange.com/questions/2538/how-to-define-additional-mode
:diminish :diminish
:hook (org-mode . org-pretty-table-mode)) :hook (org-mode . org-pretty-table-mode))
(use-package ox-hugo (use-package ox-hugo
:after ox) :after ox
:config
(defun hugo-dir-above (dir)
"Return path of Hugo project root above or at DIR.
Return nil if DIR is not in a hugo project at all."
(if (eq dir nil) nil
(if (file-exists-p (expand-file-name "config.toml" dir)) dir
(hugo-dir-above (file-name-directory (string-trim-right dir "/"))))))
(add-hook 'after-save-hook
(lambda () (let ((hugo-dir (hugo-dir-above default-directory)))
(if hugo-dir
(let ((default-directory hugo-dir))
(shell-command "hugo")))))))
;; fake indentation, other than the other fake indentation ;; fake indentation, other than the other fake indentation
(use-package adaptive-wrap (use-package adaptive-wrap