Fix ox-hugo export with internal ID links and Quartz config

- Add org-id resolution for [[id:...]] links by building ID locations
  database once before parallel export
- Handle broken file links gracefully with org-export-with-broken-links
- Fix race condition in parallel exports by pre-building ID cache
- Fix Quartz config not being applied: cp was preserving nix store hash
  prefix in filename instead of using explicit destination filename
- Continue pipeline even when some exports fail, reporting failures
- Improve error handling and logging throughout export pipeline
This commit is contained in:
Ignacio Ballesteros
2026-02-22 19:55:17 +01:00
parent c7bd37bb95
commit 1fac31dc73
9 changed files with 169 additions and 80 deletions

View File

@@ -136,10 +136,13 @@ defmodule OrgGarden.CLI do
# Full batch export
wipe(content_dir)
export_all(notes_dir, output_dir)
export_result = export_all(notes_dir, output_dir)
run_pipeline(content_dir, pipeline_opts)
generate_index(content_dir)
# Track if we had export failures
had_export_failures = match?({:error, _}, export_result)
node_path = Config.get(:node_path, "node")
IO.puts("==> Building static site with Quartz...")
@@ -166,6 +169,11 @@ defmodule OrgGarden.CLI do
end
IO.puts("==> Build complete. Output: #{Path.join(output_dir, "public")}")
# Exit with error if there were export failures
if had_export_failures do
System.halt(1)
end
end
defp parse_build_args(argv) do
@@ -191,7 +199,7 @@ defmodule OrgGarden.CLI do
# Phase 1-4: full batch export
wipe(content_dir)
export_all(notes_dir, output_dir)
export_result = export_all(notes_dir, output_dir)
run_pipeline(content_dir, pipeline_opts)
generate_index(content_dir)
@@ -203,6 +211,12 @@ defmodule OrgGarden.CLI do
IO.puts("==> Done. #{md_count} markdown files in #{content_dir}")
# Exit with error if there were export failures (unless in watch mode)
case {export_result, watch?} do
{{:error, _}, false} -> System.halt(1)
_ -> :ok
end
# Phase 5: optional watch mode
if watch? do
IO.puts("==> Watching #{notes_dir} for .org changes... (Ctrl+C to stop)")
@@ -305,20 +319,22 @@ defmodule OrgGarden.CLI do
IO.puts("==> Exporting org files from #{notes_dir}")
case OrgGarden.Export.export_all(notes_dir, output_dir) do
{:ok, 0} ->
{:ok, 0, []} ->
IO.puts(" no .org files found")
:ok
{:ok, count} ->
{:ok, count, []} ->
IO.puts(" exported #{count} file(s)")
:ok
{:error, failures} ->
IO.puts(:stderr, "\nFailed to export #{length(failures)} file(s):")
{:ok, count, failures} ->
IO.puts(" exported #{count} file(s), #{length(failures)} failed")
Enum.each(failures, fn {f, {:error, reason}} ->
IO.puts(:stderr, " #{f}: #{inspect(reason)}")
Enum.each(failures, fn {f, {:error, {:emacs_exit, code}}} ->
IO.puts(:stderr, " failed: #{f} (emacs exit code #{code})")
end)
System.halt(1)
{:error, length(failures)}
end
end