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

sitemap.lisp 1.0KB

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