Cleanup sitemap plugin a bit.
This commit is contained in:
parent
57f9aeb696
commit
3264848cde
2 changed files with 11 additions and 13 deletions
|
@ -1,28 +1,26 @@
|
|||
(defpackage :coleslaw-sitemap
|
||||
(:use :cl)
|
||||
(:import-from :coleslaw #:*config*
|
||||
#:index
|
||||
#:deploy
|
||||
#:page-url
|
||||
#:rel-path
|
||||
#:staging-dir
|
||||
#:theme-fn
|
||||
#:write-file)
|
||||
(:import-from :local-time #:format-timestring
|
||||
#:now)
|
||||
#:write-document)
|
||||
(:import-from :alexandria #:hash-table-values)
|
||||
(:export #:enable))
|
||||
|
||||
(in-package :coleslaw-sitemap)
|
||||
|
||||
(defclass sitemap (index)
|
||||
((urls :initarg :urls :reader urls)))
|
||||
|
||||
(defmethod page-url ((object sitemap)) "sitemap.xml")
|
||||
|
||||
(defmethod deploy :before (staging)
|
||||
"Render sitemap.xml under document root."
|
||||
(declare (ignore staging))
|
||||
(let ((urls (append '("" "sitemap.xml") ; empty string is for root url
|
||||
(mapcar #'page-url (hash-table-values coleslaw::*site*)))))
|
||||
(write-file (rel-path (staging-dir *config*) "sitemap.xml")
|
||||
(funcall (theme-fn 'sitemap "sitemap")
|
||||
(list :config *config*
|
||||
:urls urls
|
||||
:pubdate (format-timestring nil (now)))))))
|
||||
(let* ((urls (mapcar #'page-url (hash-table-values coleslaw::*site*)))
|
||||
(sitemap (make-instance 'sitemap :urls (append '("" "sitemap.xml") urls))))
|
||||
(write-document sitemap (theme-fn 'sitemap "sitemap"))))
|
||||
|
||||
(defun enable ())
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{template sitemap}
|
||||
<?xml version="1.0"?>{\n}
|
||||
<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>
|
||||
{foreach $url in $urls}
|
||||
{foreach $url in $content.urls}
|
||||
<url>
|
||||
<loc>{$config.domain}/{$url}</loc>
|
||||
<lastmod>{$pubdate}</lastmod>
|
||||
|
|
Loading…
Add table
Reference in a new issue