Skip to content

Commit

Permalink
Real sitemap generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
svetlyak40wt committed Apr 7, 2024
1 parent 05836db commit 4f68a4c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/feeds/base.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#:postp
#:post)
(:import-from #:local-time
#:timestamp>))
#:timestamp>)
(:import-from #:staticl/url
#:object-url)
(:import-from #:staticl/current-root
#:current-root))
(in-package #:staticl/feeds/base)


Expand Down Expand Up @@ -47,7 +51,8 @@


(defmethod staticl/content:get-target-filename ((site site) (feed-file feed-file) (stage-dir pathname))
(merge-pathnames (target-path feed-file)
(merge-pathnames (target-path
feed-file)
stage-dir))


Expand All @@ -65,6 +70,7 @@
sorted-items))))
(values))


(defmethod staticl/content:write-content-to-stream ((site site) (feed-file feed-file) stream)
(loop for item in (content-items feed-file)
for feed-entry = (make-instance 'org.shirakumo.feeder:entry
Expand All @@ -84,3 +90,10 @@
(plump-node (org.shirakumo.feeder:serialize-feed feed
(feed-type feed-file))))
(plump:serialize plump-node stream))))


(defmethod object-url ((feed-file feed-file) &key &allow-other-keys)
(let* ((root (current-root))
(relative-path (enough-namestring (target-path feed-file)
root)))
(uiop:unix-namestring relative-path)))
11 changes: 11 additions & 0 deletions src/index/base.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#:site)
(:import-from #:staticl/theme
#:template-vars)
(:import-from #:staticl/url
#:object-url)
(:import-from #:staticl/current-root
#:current-root)
(:export #:index-page
#:page-items
#:prev-page
Expand Down Expand Up @@ -116,3 +120,10 @@
(if (next-method-p)
(call-next-method content :hash hash)
(values hash)))


(defmethod object-url ((index index-page) &key &allow-other-keys)
(let* ((root (current-root))
(relative-path (enough-namestring (page-target-path index)
root)))
(uiop:unix-namestring relative-path)))
13 changes: 11 additions & 2 deletions src/plugins/sitemap.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
(:import-from #:staticl/site
#:site)
(:import-from #:serapeum
#:soft-list-of))
#:soft-list-of)
(:import-from #:cl-sitemaps/builder
#:make-url
#:render-sitemap)
(:import-from #:staticl/url
#:object-url))
(in-package #:staticl/plugins/sitemap)


Expand Down Expand Up @@ -42,7 +47,11 @@


(defmethod write-content-to-stream ((site site) (sitemap sitemap-file) (stream stream))
(write-string "TODO: make-sure to implement sitemaps" stream))
(render-sitemap (loop for item in (sitemap-content sitemap)
collect (make-url (object-url item :full t)
:changefreq :weekly
:priority 0.5))
:stream stream))


(defmethod staticl/pipeline:process-items ((site site) (node sitemap) content-items)
Expand Down

0 comments on commit 4f68a4c

Please sign in to comment.