From 186b25ac5e3a4fadcea8281d141bd311cb0e08a6 Mon Sep 17 00:00:00 2001 From: Ignacio Ballesteros Date: Sun, 22 Feb 2026 22:26:03 +0100 Subject: [PATCH] Switch ox-hugo export from TOML to YAML frontmatter TOML frontmatter interprets bare dates like 2022-10-31 as date literals requiring time components, causing parsing issues. YAML handles dates as strings by default, avoiding these problems. Changes: - export.ex: Add org-hugo-front-matter-format set to yaml - index.ex: Update title regex to match YAML format (title: vs title =) - quartz.config.ts: Use default FrontMatter plugin (YAML) instead of TOML --- lib/org_garden/export.ex | 3 +++ lib/org_garden/index.ex | 7 ++++--- quartz-config/quartz.config.ts | 4 +--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/org_garden/export.ex b/lib/org_garden/export.ex index 3f85c8c..cf2ac44 100644 --- a/lib/org_garden/export.ex +++ b/lib/org_garden/export.ex @@ -73,6 +73,9 @@ defmodule OrgGarden.Export do (format "[cite:%s]" (string-join keys ";"))))) """, "--eval", "(setq org-cite-export-processors '((t passthrough)))", + # Use YAML frontmatter instead of TOML to avoid date parsing issues + # (TOML interprets bare dates like 2022-10-31 as date literals requiring time) + "--eval", "(setq org-hugo-front-matter-format 'yaml)", "--eval", ~s[(setq org-hugo-base-dir "#{output_dir}")], "--eval", ~s[(setq org-hugo-default-section-directory "#{section}")], "--visit", orgfile, diff --git a/lib/org_garden/index.ex b/lib/org_garden/index.ex index 8909698..9c38229 100644 --- a/lib/org_garden/index.ex +++ b/lib/org_garden/index.ex @@ -29,7 +29,8 @@ defmodule OrgGarden.Index do path |> File.read!() |> then(fn content -> - case Regex.run(~r/^title\s*=\s*"(.+)"/m, content) do + # Match YAML frontmatter: title: "value" or title: value + case Regex.run(~r/^title:\s*"?(.+?)"?\s*$/m, content) do [_, t] -> t _ -> slug end @@ -76,8 +77,8 @@ defmodule OrgGarden.Index do defp generated_index?(content) do # Our generated index uses "title: Index" in YAML frontmatter. - # ox-hugo uses TOML frontmatter (title = "..."), so this won't - # match user-exported files. + # ox-hugo also uses YAML frontmatter now, so we check for our specific + # title to distinguish generated vs user-exported index files. String.contains?(content, "title: Index") end end diff --git a/quartz-config/quartz.config.ts b/quartz-config/quartz.config.ts index a8540f7..d2fb21e 100644 --- a/quartz-config/quartz.config.ts +++ b/quartz-config/quartz.config.ts @@ -55,7 +55,7 @@ const config: QuartzConfig = { }, plugins: { transformers: [ - Plugin.FrontMatter({ delimiters: "+++", language: "toml" }), + Plugin.FrontMatter(), Plugin.CreatedModifiedDate({ priority: ["frontmatter", "git", "filesystem"], }), @@ -68,8 +68,6 @@ const config: QuartzConfig = { }), // OxHugoFlavouredMarkdown must come before GitHubFlavoredMarkdown. // Note: not compatible with ObsidianFlavoredMarkdown — use one or the other. - // If ox-hugo exports TOML frontmatter, change FrontMatter to: - // Plugin.FrontMatter({ delims: "+++", language: "toml" }) Plugin.OxHugoFlavouredMarkdown(), Plugin.GitHubFlavoredMarkdown(), Plugin.TableOfContents(),