coleslaw/plugins/sitemap.lisp

32 lines
1,001 B
Common Lisp
Raw Normal View History

2013-04-28 10:11:38 -04:00
(defpackage :coleslaw-sitemap
2013-04-27 02:16:22 +08:00
(:use :cl)
(:import-from :coleslaw
#:*config*
#:deploy
#:find-all
2013-04-28 10:11:38 -04:00
#:make-pubdate
2013-04-27 02:16:22 +08:00
#:page-url
#:rel-path
#:staging-dir
#:theme-fn
#:write-file)
(:import-from :local-time
#:format-timestring
#:now)
2013-04-27 02:16:22 +08:00
(:export #:enable))
2013-04-28 10:11:38 -04:00
(in-package :coleslaw-sitemap)
2013-04-27 02:16:22 +08:00
(defmethod deploy :before (staging)
2014-04-15 19:05:52 -04:00
"Render sitemap.xml under document root."
(declare (ignore staging))
2013-04-28 10:11:38 -04:00
(let ((urls (append '("" "sitemap.xml") ; empty string is for root url
2014-04-15 19:05:52 -04:00
(mapcar #'page-url (hash-table-values coleslaw::*site*)))))
(write-file (rel-path (staging-dir *config*) "sitemap.xml")
2014-04-15 19:05:52 -04:00
(funcall (theme-fn 'sitemap "sitemap")
2013-04-28 10:11:38 -04:00
(list :config *config*
2013-04-27 02:16:22 +08:00
:urls urls
:pubdate (format-timestring nil (now)))))))
2013-04-27 02:16:22 +08:00
(defun enable ())