From 7f831336ee584ce5d54a0c7c7486a82757b3eda4 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Thu, 6 Apr 2023 15:32:15 +0300 Subject: [PATCH] * publish.el: don't add /index.html in canonical urls --- publish.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/publish.el b/publish.el index e24b06e..497827f 100644 --- a/publish.el +++ b/publish.el @@ -71,10 +71,15 @@ (pubDate nil ,(substring file 0 10)) (description nil ,(format "" (esy/dom-to-string (car (dom-by-id dom "content"))))))))) +(defun esy/publish-file-url (file) + (concat "https://eshelyaron.com/" + (let ((path (file-relative-name file esy/publish-out-directory))) + (if (string= (file-name-base file) "index") + (file-name-directory path) + path)))) + (defun esy/publish-sitemap (plist) - (let ((locs (mapcar (lambda (file) - (concat "https://eshelyaron.com/" - (file-relative-name file esy/publish-out-directory))) + (let ((locs (mapcar #'esy/publish-file-url (directory-files-recursively esy/publish-out-directory (rx ".html" eos))))) (with-temp-buffer @@ -137,8 +142,7 @@ (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))) + (esy/publish-file-url file)) nil t)) (basic-save-buffer)))) -- 2.39.2