aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-11-21 10:17:11 -0800
committerGravatar Tom Willemse2020-11-22 15:44:09 -0800
commit88de93b36013ffa9552fc9fb4e7af64aab803151 (patch)
treec0f83c1b44a2e175b351040ae5088b5b5239a464
parentc8856eb79715a533d995d4a8ef9873a02879bc19 (diff)
downloadnew-ryuslash.org-88de93b36013ffa9552fc9fb4e7af64aab803151.tar.gz
new-ryuslash.org-88de93b36013ffa9552fc9fb4e7af64aab803151.zip
Add Atom feed from my source control system to each page
-rw-r--r--publish.el22
1 files changed, 22 insertions, 0 deletions
diff --git a/publish.el b/publish.el
index 57c3708..7823a46 100644
--- a/publish.el
+++ b/publish.el
@@ -30,6 +30,12 @@
(require 'rainbow-delimiters)
(require 'subr-x)
+(defconst publish-root
+ (file-name-directory
+ (or load-file-name
+ (buffer-file-name)))
+ "The directory where ‘oni-org’ was loaded from.")
+
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(defun publish-calculate-reading-time (buffer)
@@ -89,5 +95,21 @@
:publishing-directory "public/")
("all" :components ("index" "posts" "assets"))))
+(defvar publish-feed-url-format
+ ;"https://gitlab.com/ryuslash/ryuslash.org/-/commits/master/%s?feed_token=Rf8otgpS8YEiYakJN4NR&format=atom"
+ "https://code.ryuslash.org/new-ryuslash.org/atom/%s?h=master"
+ "Format string for the URL to the page’s atom feed.")
+
+(add-hook 'org-export-before-processing-hook
+ (lambda (backend)
+ (when (eq backend 'html)
+ (let ((file-name (if (string= (buffer-file-name)
+ (expand-file-name "index.org"))
+ ""
+ (file-relative-name (buffer-file-name) publish-root))))
+ (insert "#+HTML_HEAD: <link rel=\"alternate\" type=\"application/atom+xml\" href=\""
+ (format publish-feed-url-format file-name)
+ "\" title=\"Atom Feed\"/>\n")))))
+
(provide 'publish)
;;; publish.el ends here