diff --git a/config.el b/config.el index f4bc5ea..637cf3f 100644 --- a/config.el +++ b/config.el @@ -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))))