adding md -> org wrapper
This commit is contained in:
105
build-site.el
105
build-site.el
@@ -215,17 +215,52 @@ A file has comments if:
|
||||
(add-to-list 'org-export-filter-body-functions
|
||||
#'z/org-html-insert-comments-into-body)
|
||||
|
||||
(defun z/lima-sitemap-format-entry (entry style project)
|
||||
"Format sitemap ENTRY for lima, ensuring .html links."
|
||||
(let* ((file (if (listp entry) (car entry) entry))
|
||||
(title (org-publish-find-title file project))
|
||||
(base (file-name-base file)))
|
||||
(format "[[file:%s.html][%s]]"
|
||||
base
|
||||
(or title base))))
|
||||
|
||||
|
||||
;; (defun z/publish-lima-file (plist filename pub-dir)
|
||||
;; "Publish Org or Markdown file from lima directory."
|
||||
;; (let* ((ext (file-name-extension filename))
|
||||
;; (base (file-name-base filename))
|
||||
;; (output-file (expand-file-name
|
||||
;; (concat base ".html")
|
||||
;; pub-dir)))
|
||||
|
||||
;; ;; Ensure output directory exists
|
||||
;; (make-directory pub-dir t)
|
||||
|
||||
;; (cond
|
||||
;; ;; ORG FILES
|
||||
;; ((string= ext "org")
|
||||
;; (org-publish-org-to 'z-html filename ".html" plist pub-dir))
|
||||
|
||||
;; ;; MARKDOWN FILES
|
||||
;; ((string= ext "md")
|
||||
;; (message "Converting %s → %s" filename output-file)
|
||||
;; (let ((exit-code
|
||||
;; (call-process
|
||||
;; "pandoc"
|
||||
;; nil
|
||||
;; "*pandoc-output*"
|
||||
;; t
|
||||
;; filename
|
||||
;; "-o"
|
||||
;; output-file
|
||||
;; "--standalone")))
|
||||
;; (unless (eq exit-code 0)
|
||||
;; (error "Pandoc failed with exit code %s" exit-code)))))))
|
||||
|
||||
(defun z/publish-lima-file (plist filename pub-dir)
|
||||
"Publish Org or Markdown file from lima directory."
|
||||
(let* ((ext (file-name-extension filename))
|
||||
(base (file-name-base filename))
|
||||
(output-file (expand-file-name
|
||||
(concat base ".html")
|
||||
pub-dir)))
|
||||
|
||||
;; Ensure output directory exists
|
||||
(make-directory pub-dir t)
|
||||
(base (file-name-base filename)))
|
||||
|
||||
(cond
|
||||
;; ORG FILES
|
||||
@@ -234,21 +269,48 @@ A file has comments if:
|
||||
|
||||
;; MARKDOWN FILES
|
||||
((string= ext "md")
|
||||
(message "Converting %s → %s" filename output-file)
|
||||
(let ((exit-code
|
||||
(call-process
|
||||
"pandoc"
|
||||
nil
|
||||
"*pandoc-output*"
|
||||
t
|
||||
filename
|
||||
"-o"
|
||||
output-file
|
||||
"--standalone")))
|
||||
(unless (eq exit-code 0)
|
||||
(error "Pandoc failed with exit code %s" exit-code)))))))
|
||||
(let* ((temp-org
|
||||
(expand-file-name
|
||||
(concat base ".org")
|
||||
(make-temp-file "lima-build-" t)))) ;; temp directory
|
||||
|
||||
;; Convert Markdown → Org
|
||||
(call-process
|
||||
"pandoc"
|
||||
nil nil nil
|
||||
filename
|
||||
"-f" "markdown"
|
||||
"-t" "org"
|
||||
"-o" temp-org)
|
||||
|
||||
;; Ensure title exists
|
||||
(with-temp-buffer
|
||||
(insert-file-contents temp-org)
|
||||
(goto-char (point-min))
|
||||
(unless (re-search-forward "^#\\+TITLE:" nil t)
|
||||
(goto-char (point-min))
|
||||
(insert "#+TITLE: " base "\n\n"))
|
||||
(write-region (point-min) (point-max) temp-org))
|
||||
|
||||
;; Publish using ORIGINAL base name
|
||||
(let ((output-file
|
||||
(expand-file-name
|
||||
(concat base ".html")
|
||||
pub-dir)))
|
||||
(org-publish-org-to
|
||||
'z-html
|
||||
temp-org
|
||||
".html"
|
||||
plist
|
||||
pub-dir)
|
||||
|
||||
;; Rename to correct base if needed
|
||||
(let ((generated
|
||||
(expand-file-name
|
||||
(concat (file-name-base temp-org) ".html")
|
||||
pub-dir)))
|
||||
(when (file-exists-p generated)
|
||||
(rename-file generated output-file t)))))))))
|
||||
|
||||
|
||||
(setq org-html-htmlize-output-type 'css)
|
||||
@@ -439,8 +501,9 @@ A file has comments if:
|
||||
:sitemap-title "Lima"
|
||||
:sitemap-style list
|
||||
:sitemap-sort-files anti-chronologically
|
||||
:sitemap-format-entry z/lima-sitemap-format-entry
|
||||
:html-head ,z-shared-head)
|
||||
|
||||
|
||||
("org-assets"
|
||||
:base-directory ,(site-path "assets/")
|
||||
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|svg\\|pdf\\|woff\\|woff2\\|ttf"
|
||||
|
||||
Reference in New Issue
Block a user