Extract ‘publish-get-summary-from-file’

This commit is contained in:
Tom Willemse 2023-07-25 11:45:22 -07:00
parent 4ccfc01c28
commit 1d6a9213cb

View file

@ -52,6 +52,20 @@
time time
(if (= time 1) "" "s"))) (if (= time 1) "" "s")))
(defun publish-get-summary-from-file (file props)
(format "* %s\n:PROPERTIES:\n:CUSTOM_ID: %s\n:PUBDATE: %s\n:RSS_PERMALINK: %s\n:END:\n\n%s\n\n[[file:%s][Read More]]\n\n"
(car (org-publish-find-property file :title props))
(file-name-nondirectory file)
(format-time-string "[%Y-%m-%d %a %H:%M]" (org-timestamp-to-time (car (org-publish-find-property file :date props))))
(file-name-nondirectory file)
(car (org-map-entries (lambda () (let ((element-data (cadr (org-element-at-point))))
(buffer-substring-no-properties
(map-elt element-data :contents-begin)
(map-elt element-data :contents-end))))
"summary"
(list file)))
(file-name-nondirectory file)))
(defun publish-generate-index (props) (defun publish-generate-index (props)
"Generate an index from my posts. "Generate an index from my posts.
Argument PROPS Argument PROPS
@ -62,19 +76,7 @@ Argument PROPS
(insert "#+options: num:nil\n") (insert "#+options: num:nil\n")
(insert "\n") (insert "\n")
(apply 'insert (apply 'insert
(mapcar (lambda (file) (mapcar (lambda (file) (publish-get-summary-from-file file props))
(format "* %s\n:PROPERTIES:\n:CUSTOM_ID: %s\n:PUBDATE: %s\n:RSS_PERMALINK: %s\n:END:\n\n%s\n\n[[file:%s][Read More]]\n\n"
(car (org-publish-find-property file :title props))
(file-name-nondirectory file)
(format-time-string "[%Y-%m-%d %a %H:%M]" (org-timestamp-to-time (car (org-publish-find-property file :date props))))
(file-name-nondirectory file)
(car (org-map-entries (lambda () (let ((element-data (cadr (org-element-at-point))))
(buffer-substring-no-properties
(map-elt element-data :contents-begin)
(map-elt element-data :contents-end))))
"summary"
(list file)))
(file-name-nondirectory file)))
(take 30 (reverse files)))) (take 30 (reverse files))))
(write-file "posts/index.org")))) (write-file "posts/index.org"))))