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
This commit is contained in:
Ignacio Ballesteros
2026-02-22 22:26:03 +01:00
parent 798401539f
commit 186b25ac5e
3 changed files with 8 additions and 6 deletions

View File

@@ -73,6 +73,9 @@ defmodule OrgGarden.Export do
(format "[cite:%s]" (string-join keys ";"))))) (format "[cite:%s]" (string-join keys ";")))))
""", """,
"--eval", "(setq org-cite-export-processors '((t passthrough)))", "--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-base-dir "#{output_dir}")],
"--eval", ~s[(setq org-hugo-default-section-directory "#{section}")], "--eval", ~s[(setq org-hugo-default-section-directory "#{section}")],
"--visit", orgfile, "--visit", orgfile,

View File

@@ -29,7 +29,8 @@ defmodule OrgGarden.Index do
path path
|> File.read!() |> File.read!()
|> then(fn content -> |> 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 [_, t] -> t
_ -> slug _ -> slug
end end
@@ -76,8 +77,8 @@ defmodule OrgGarden.Index do
defp generated_index?(content) do defp generated_index?(content) do
# Our generated index uses "title: Index" in YAML frontmatter. # Our generated index uses "title: Index" in YAML frontmatter.
# ox-hugo uses TOML frontmatter (title = "..."), so this won't # ox-hugo also uses YAML frontmatter now, so we check for our specific
# match user-exported files. # title to distinguish generated vs user-exported index files.
String.contains?(content, "title: Index") String.contains?(content, "title: Index")
end end
end end

View File

@@ -55,7 +55,7 @@ const config: QuartzConfig = {
}, },
plugins: { plugins: {
transformers: [ transformers: [
Plugin.FrontMatter({ delimiters: "+++", language: "toml" }), Plugin.FrontMatter(),
Plugin.CreatedModifiedDate({ Plugin.CreatedModifiedDate({
priority: ["frontmatter", "git", "filesystem"], priority: ["frontmatter", "git", "filesystem"],
}), }),
@@ -68,8 +68,6 @@ const config: QuartzConfig = {
}), }),
// OxHugoFlavouredMarkdown must come before GitHubFlavoredMarkdown. // OxHugoFlavouredMarkdown must come before GitHubFlavoredMarkdown.
// Note: not compatible with ObsidianFlavoredMarkdown — use one or the other. // 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.OxHugoFlavouredMarkdown(),
Plugin.GitHubFlavoredMarkdown(), Plugin.GitHubFlavoredMarkdown(),
Plugin.TableOfContents(), Plugin.TableOfContents(),