emacs-使用ox-rss导出rss的xml文件
设置 ox-rss
, 可参考此链接:
https://nicolasknoebber.com/posts/blogging-with-emacs-and-org.html#org9edef43
("rss"
:publishing-directory ,my/publish-directory
:base-directory ,website-directory
:base-extension "org"
:exclude ".*"
:include ,(my/ox-files)
:publishing-function publish-posts-rss-feed
:rss-extension "xml"
:html-link-home "https://tomoemami.github.io/blog"
:html-link-use-abs-url t
:html-link-org-files-as-html t
:auto-sitemap t
:sitemap-function posts-rss-feed
:sitemap-title "TomoeMami's Blog"
:sitemap-filename "rss.org"
:sitemap-style list
:sitemap-sort-files anti-chronologically
:sitemap-format-entry format-posts-rss-feed-entry)
(require 'ox-rss)
(defun posts-rss-feed (title list)
"Generate a sitemap of posts that is exported as a RSS feed.
TITLE is the title of the RSS feed. LIST is an internal
representation for the files to include. PROJECT is the current
project."
(concat
"#+TITLE: " title "\n\n"
(org-list-to-subtree list)))
(defun publish-posts-rss-feed (plist filename dir)
"Publish PLIST to RSS when FILENAME is rss.org.
DIR is the location of the output."
(if (equal "rss.org" (file-name-nondirectory filename))
(org-rss-publish-to-rss plist filename dir)))
(defun format-posts-rss-feed-entry (entry _style project)
"Format ENTRY for the posts RSS feed in PROJECT."
(let* (
(title (org-publish-find-title entry project))
(link (concat (file-name-sans-extension entry) ".html"))
(pubdate (format-time-string (cdr org-time-stamp-formats)
(org-publish-find-date entry project))))
(message pubdate)
(format "%s
:properties:
:rss_permalink: %s
:pubdate: %s
:ROAM_EXCLUDE: t
:end:\n"
title
link
pubdate)))
此处 :ROAM_EXCLUDE: t
是为了避免org-roam把生成的 rss.org
文件添加到org-roam的数据库中。
然后需要修改 org-roam
的 org-roam-capture-templates
,为文件添加 DATE
属性:
(setq org-roam-capture-templates
'(("d" "default" plain "[%<%Y-%m-%d %H:%M>]\n%?" :target
(file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+date: <%<%Y-%m-%d %H:%M>>
")
:unnarrowed t)))
这样一来,rss生成函数就能读取到文件创建的日期并将其作为RSS的 pubdate
了。
根据 这个PR ,目前 org-publish
会缓存 :title/:date/:index
属性且不更新,如果手动修改了以上属性需要删除掉缓存文件再重新导出。