aboutsummaryrefslogtreecommitdiff
path: root/publish.el
diff options
context:
space:
mode:
authorJacob Janzen <jjanzenn@proton.me>2024-04-14 19:50:27 -0500
committerJacob Janzen <jjanzenn@proton.me>2024-04-14 19:50:27 -0500
commitf6749b0bf38a2b8be0914115459cc7ef492acf62 (patch)
tree757775551001f8f7cb22041db288cb00d5eae3f9 /publish.el
parentefa001c00cf1bdbbf0512918c33b7887ec9ccce2 (diff)
try adding RSS
Diffstat (limited to 'publish.el')
-rw-r--r--publish.el49
1 files changed, 45 insertions, 4 deletions
diff --git a/publish.el b/publish.el
index 91b4cda..185f391 100644
--- a/publish.el
+++ b/publish.el
@@ -9,8 +9,8 @@
(require 'org)
(require 'ox-html)
+
(defun my/org-publish-org-sitemap-format (entry style project)
- "custom sitemap entry formatting: add date"
(cond ((not (directory-name-p entry))
(format "(%s) [[file:%s][%s]]\n"
(format-time-string "%Y-%m-%d"
@@ -18,6 +18,30 @@
entry
(org-publish-find-title entry project)))))
+(defun my/org-rss-publish-to-rss (plist filename pub-dir)
+ (if (equal "rss.org" (file-name-nondirectory filename))
+ (org-rss-publish-to-rss plist filename pub-dir)))
+
+(defun my/format-rss-feed (title list)
+ (concat "#+TITLE: " title "\n\n"
+ (org-list-to-subtree list '(:icount "" :istart ""))))
+
+(defun my/format-rss-feed-entry (entry style project)
+ (cond ((not (directory-name-p entry))
+ (let* ((file (org-publish--expand-file-name entry project))
+ (title (org-publish-find-title entry project))
+ (date (format-time-string "%Y-%m-%d" (org-publish-find-date entry project)))
+ (link (concat (file-name-sans-extension entry) ".html")))
+ (with-temp-buffer
+ (insert (format "* [[file:%s][%s]]\n" file title))
+ (org-set-property "RSS_PERMALINK" link)
+ (org-set-property "PUBDATE" date)
+ (insert-file-contents file)
+ (buffer-string))))
+ ((eq style 'tree)
+ (file-name-nondirectory (directory-file-name entry)))
+ (t entry)))
+
(setq org-publish-project-alist
'(
("org-notes"
@@ -30,7 +54,7 @@
:headline-levels 4
:section-numbers nil
:html-head "<link rel='stylesheet' href='/css/stylesheet.css' type='text/css'/>"
- :html-preamble "<div class='topnav'><a href='/index.html'>Home</a><a href='/projects.html'>Projects</a><a href='/blog'>Blog</a><a href='/config.html'>Dotfiles</a><a href='/about.html'>About Me</a></div>"
+ :html-preamble "<div class='topnav'><a href='/'>Home</a><a href='/projects.html'>Projects</a><a href='/blog'>Blog</a><a href='/config.html'>Dotfiles</a><a href='/about.html'>About Me</a></div>"
:html-postamble nil)
("org-static"
:base-directory "~/website/"
@@ -51,18 +75,35 @@
:headline-levels 4
:section-numbers nil
:html-head "<link rel='stylesheet' href='/css/stylesheet.css' type='text/css'/>"
- :html-preamble "<div class='topnav'><a href='/index.html'>Home</a><a href='/projects.html'>Projects</a><a href='/blog'>Blog</a><a href='/config.html'>Dotfiles</a><a href='/about.html'>About Me</a></div>"
+ :html-preamble "<div class='topnav'><a href='/'>Home</a><a href='/projects.html'>Projects</a><a href='/blog'>Blog</a><a href='/config.html'>Dotfiles</a><a href='/about.html'>About Me</a></div>"
:html-postamble nil
:auto-sitemap t
:sitemap-filename "index.org"
:sitemap-format-entry my/org-publish-org-sitemap-format
:sitemap-sort-files anti-chronologically
:sitemap-title "Blog")
+ ("org-rss"
+ :base-directory "~/blog/"
+ :base-extension "org"
+ :recursive t
+ :exclude (regexp-opt '("rss.org" "index.org"))
+ :publishing-function my/org-rss-publish-to-rss
+ :publishing-directory "~/public_html"
+ :rss-extension "xml"
+ :html-link-use-abs-url t
+ :html-link-org-files-as-html t
+ :auto-sitemap t
+ :sitemap-filename "rss.org"
+ :sitemap-title "Jacob Janzen's Blog"
+ :sitemap-style list
+ :sitemap-sort-files anti-chronologically
+ :sitemap-function my/format-rss-feed
+ :sitemap-format-entry my/format-rss-feed-entry)
("org-config"
:base-directory "~/.doom.d/"
:base-extension "org"
:html-head "<link rel='stylesheet' href='/css/stylesheet.css' type='text/css'/>"
- :html-preamble "<div class='topnav'><a href='/index.html'>Home</a><a href='/projects.html'>Projects</a><a href='/blog'>Blog</a><a href='/config.html'>Dotfiles</a><a href='/about.html'>About Me</a></div>"
+ :html-preamble "<div class='topnav'><a href='/'>Home</a><a href='/projects.html'>Projects</a><a href='/blog'>Blog</a><a href='/config.html'>Dotfiles</a><a href='/about.html'>About Me</a></div>"
:html-postamble nil
:publishing-directory "~/public_html"
:publishing-function org-html-publish-to-html