Flexible Lisp Blogware. Fork for personal use. Mirrored from https://github.com/kingcons/coleslaw originally.

sitemap.lisp 1.1KB

12345678910111213141516171819202122232425262728293031
  1. (defpackage :coleslaw-sitemap
  2. (:use :cl)
  3. (:import-from :coleslaw #:*config*
  4. #:deploy
  5. #:find-all
  6. #:make-pubdate
  7. #:page-url
  8. #:rel-path
  9. #:staging-dir
  10. #:theme-fn
  11. #:write-file)
  12. (:import-from :local-time #:format-timestring
  13. #:now)
  14. (:import-from :alexandria #:hash-table-values)
  15. (:export #:enable))
  16. (in-package :coleslaw-sitemap)
  17. (defmethod deploy :before (staging)
  18. "Render sitemap.xml under document root."
  19. (declare (ignore staging))
  20. (let ((urls (append '("" "sitemap.xml") ; empty string is for root url
  21. (mapcar #'page-url (hash-table-values coleslaw::*site*)))))
  22. (write-file (rel-path (staging-dir *config*) "sitemap.xml")
  23. (funcall (theme-fn 'sitemap "sitemap")
  24. (list :config *config*
  25. :urls urls
  26. :pubdate (format-timestring nil (now)))))))
  27. (defun enable ())