From f7a68db0ec13781dd310877d354c59deb28d4a56 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 2 Apr 2023 09:32:28 +0300 Subject: [PATCH] add canonical tags to all html pages --- publish.el | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/publish.el b/publish.el index 63d6267..e738fe3 100644 --- a/publish.el +++ b/publish.el @@ -136,7 +136,19 @@ (with-current-buffer (find-file-noselect (expand-file-name "index.org" dir)) (org-update-all-dblocks)))) +(defun esy/publish-add-canonical-tags (_plist) + (dolist (file (directory-files-recursively esy/publish-out-directory + (rx ".html" eos))) + (with-current-buffer (find-file-noselect file) + (when (search-forward "" nil t) + (replace-match (format "" + (concat "https://eshelyaron.com/" + (file-relative-name file esy/publish-out-directory))) + nil t)) + (basic-save-buffer)))) + (defun esy/publish-completion-function (plist) + (esy/publish-add-canonical-tags plist) (esy/publish-posts plist) (esy/publish-sitemap plist)) @@ -196,10 +208,12 @@ :html-head (esy/dom-to-string '(link ((rel . "stylesheet") (href . "/style.css") (type . "text/css")))) - :html-head-extra (esy/dom-to-string '(link ((rel . "alternate") - (href . "/rss.xml") - (type . "application/rss+xml") - (title . "RSS feed of eshelyaron.com")))) + :html-head-extra (concat (esy/dom-to-string + '(link ((rel . "alternate") + (href . "/rss.xml") + (type . "application/rss+xml") + (title . "RSS feed of eshelyaron.com")))) + "\n") :html-preamble-format (list (list -- 2.39.2