{ Josh Rendek }

<3 Go & Kubernetes

If you’re using ox-hugo and want to have it generate markdown files with the date prefixing the markdown title you can use this snippet to do it on save with org-hugo-auto-export-mode turned on.

 1(defun ox-date-slug-prop ()
 2  (interactive)
 3  (let ((dt (format-time-string "%Y-%m-%d" (apply #'encode-time (org-parse-time-string (org-entry-get (point) "EXPORT_DATE")))))
 4        (slug (org-hugo-slug (org-get-heading :no-tags :no-todo))))
 5    (org-set-property "EXPORT_FILE_NAME" (format "%s-%s" dt slug))))
 7(defun my-setup-hugo-auto-export ()
 8  "Set up an advice to call `my-ox-date-slug-before-save' before `org-hugo-auto-export'."
 9  (advice-add 'org-hugo-export-wim-to-md :before #'ox-date-slug-prop))
comments powered by Disqus