diff --git a/publish.el b/publish.el index 11aca3d..1b3bac2 100644 --- a/publish.el +++ b/publish.el @@ -52,6 +52,20 @@ time (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) "Generate an index from my posts. Argument PROPS @@ -62,19 +76,7 @@ Argument PROPS (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" - (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))) + (mapcar (lambda (file) (publish-get-summary-from-file file props)) (take 30 (reverse files)))) (write-file "posts/index.org"))))