Fix org-hugo link export to render proper Markdown links

- Handle http/https/ftp links explicitly using :raw-link for full URL
- Resolve org-id links via org-id-find to use filename slug instead of raw UUID
- Replace unused path alias with raw-link property

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Shawn Borton 2026-02-21 14:07:43 -06:00
parent 5594248f21
commit b1fbc1d2da

View file

@ -647,15 +647,23 @@
"Render org links as vanilla Markdown links instead of Hugo relref."
(let* ((type (org-element-property :type link))
(raw-path (org-element-property :path link))
(path raw-path))
(raw-link (org-element-property :raw-link link)))
(cond
;; File links - convert to plain markdown
;; External links - plain markdown
((member type '("http" "https" "ftp"))
(format "[%s](%s)" (or desc raw-link) raw-link))
;; ID links - resolve org-id to file slug
((string= type "id")
(format "[%s](%s)" (or desc path) path))
(let* ((id-location (org-id-find raw-path))
(file (when id-location (car id-location)))
(slug (if file
(file-name-sans-extension (file-name-nondirectory file))
raw-path)))
(format "[%s](%s)" (or desc slug) slug)))
;; Fuzzy/internal links - convert to anchor links
((string= type "fuzzy")
(format "[%s](#%s)" (or desc path)
(org-hugo-slug path)))
(format "[%s](#%s)" (or desc raw-path)
(org-hugo-slug raw-path)))
;; Default: use original behavior for other link types
(t nil))))