(defun templated-html-create-sitemap-xml (output directory base-url &rest regexp)
"https://www.sitemaps.org/protocol.html"
(let* ((rx (or regexp "\\.html$")))
(with-temp-file output
(insert "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<urlset
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n")
(insert
(format
"<url>\n <loc>%s</loc>\n <priority>1.00</priority>\n</url>\n"
base-url))
(cl-loop for file in (directory-files-recursively directory rx)
do (insert
(format
"<url>\n <loc>%s/%s</loc>\n <lastmod>%s</lastmod>\n <priority>%s</priority>\n</url>\n"
base-url (file-relative-name file directory)
(format-time-string "%Y-%m-%d" (file-attribute-status-change-time (file-attributes file)))
(if (s-equals? (f-base file) "index") "0.75" "0.5"))))
(insert "</urlset>"))))
(defun make-sitemap ()
(templated-html-create-sitemap-xml
"~/org/dist/public_html/sitemap.xml"
"~/org/dist/public_html"
"https://7696122.github.io"))
;; (make-sitemap)