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,17 +52,7 @@
time time
(if (= time 1) "" "s"))) (if (= time 1) "" "s")))
(defun publish-generate-index (props) (defun publish-get-summary-from-file (file props)
"Generate an index from my posts.
Argument PROPS
."
(let ((files (directory-files "posts/" t (rx bos (= 8 digit) "-" (= 4 digit) "-" (one-or-more nonl) (not "~") eos))))
(with-temp-buffer
(insert "#+title: ryuslash's blog\n")
(insert "#+options: num:nil\n")
(insert "\n")
(apply 'insert
(mapcar (lambda (file)
(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" (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)) (car (org-publish-find-property file :title props))
(file-name-nondirectory file) (file-name-nondirectory file)
@ -75,6 +65,18 @@ Argument PROPS
"summary" "summary"
(list file))) (list file)))
(file-name-nondirectory file))) (file-name-nondirectory file)))
(defun publish-generate-index (props)
"Generate an index from my posts.
Argument PROPS
."
(let ((files (directory-files "posts/" t (rx bos (= 8 digit) "-" (= 4 digit) "-" (one-or-more nonl) (not "~") eos))))
(with-temp-buffer
(insert "#+title: ryuslash's blog\n")
(insert "#+options: num:nil\n")
(insert "\n")
(apply 'insert
(mapcar (lambda (file) (publish-get-summary-from-file file props))
(take 30 (reverse files)))) (take 30 (reverse files))))
(write-file "posts/index.org")))) (write-file "posts/index.org"))))