]> git.eshelyaron.com Git - esy-publish.git/commitdiff
* publish.el: don't add /index.html in canonical urls
authorEshel Yaron <me@eshelyaron.com>
Thu, 6 Apr 2023 12:32:15 +0000 (15:32 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 6 Apr 2023 12:32:15 +0000 (15:32 +0300)
publish.el

index e24b06e364ee6551ebabf92a27e12264fb42aa28..497827f520bbd6a83401dfb060d2bb6d87d96f56 100644 (file)
              (pubDate nil ,(substring file 0 10))
              (description nil ,(format "<![CDATA[%s]]>" (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
     (with-current-buffer (find-file-noselect file)
       (when (search-forward "<!-- insert canonical tag here -->" nil t)
         (replace-match (format "<link rel=\"canonical\" href=\"%s\" />"
-                               (concat "https://eshelyaron.com/"
-                                       (file-relative-name file esy/publish-out-directory)))
+                               (esy/publish-file-url file))
                        nil t))
       (basic-save-buffer))))