From ebd8b2ce83941386b196e663d8f8ba83d7ce44c1 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 14 Feb 2026 00:45:55 -0600 Subject: test: add ERT coverage for modeline-config and hugo-config Add 67 tests across 6 new test files for modeline and hugo modules. Refactor hugo-config: extract post-file-path and post-template helpers from interactive new-post function for testability. Update todo.org with test audit (31 modules), priority adjustments, and task cleanup. --- modules/hugo-config.el | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'modules/hugo-config.el') diff --git a/modules/hugo-config.el b/modules/hugo-config.el index 8bc2cef2..33245fd4 100644 --- a/modules/hugo-config.el +++ b/modules/hugo-config.el @@ -34,31 +34,42 @@ ;; ----------------------------- Hugo Blog Functions --------------------------- +(defun cj/hugo--post-file-path (title) + "Return the file path for a Hugo post with TITLE. +Generates a slug from TITLE using `org-hugo-slug' and returns +the full path under `cj/hugo-content-org-dir'. +Assumes ox-hugo is already loaded (via use-package declaration above)." + (let ((slug (org-hugo-slug title))) + (expand-file-name (concat slug ".org") cj/hugo-content-org-dir))) + +(defun cj/hugo--post-template (title date) + "Return the Org front matter template for a Hugo post. +TITLE is the post title, DATE is the date string (YYYY-MM-DD)." + (format "#+hugo_base_dir: ../../ +#+hugo_section: log +#+hugo_auto_set_lastmod: t +#+title: %s +#+date: %s +#+hugo_tags: +#+hugo_draft: true +#+hugo_custom_front_matter: :description \"\" + +" title date)) + (defun cj/hugo-new-post () "Create a new Hugo blog post as a standalone Org file. Prompts for title, generates the slug filename, and opens the new file with Hugo front matter keywords pre-filled." (interactive) - (require 'ox-hugo) (let* ((title (read-from-minibuffer "Post Title: ")) - (slug (org-hugo-slug title)) - (date (format-time-string "%Y-%m-%d")) - (file (expand-file-name (concat slug ".org") cj/hugo-content-org-dir))) + (file (cj/hugo--post-file-path title)) + (date (format-time-string "%Y-%m-%d"))) (when (file-exists-p file) (user-error "Post already exists: %s" file)) (unless (file-directory-p cj/hugo-content-org-dir) (make-directory cj/hugo-content-org-dir t)) (find-file file) - (insert (format "#+hugo_base_dir: ../../ -#+hugo_section: log -#+hugo_auto_set_lastmod: t -#+title: %s -#+date: %s -#+hugo_tags: -#+hugo_draft: true -#+hugo_custom_front_matter: :description \"\" - -" title date)) + (insert (cj/hugo--post-template title date)) (save-buffer) (message "New post: %s" file))) -- cgit v1.2.3