Skip to content

Commit 76c498a

Browse files
committed
build: Generate a sitemap.txt file
This is probably not very useful or important, but frog did it, so we might as well do it, too, for completeness.
1 parent 92c4a48 commit 76c498a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

blog/build.rkt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@
159159
out-path
160160
(λ~>> (write-xml (feed type posts #:tag tag)))))
161161

162+
(define (build-sitemap posts)
163+
(define site-path "/sitemap.txt")
164+
(eprintf "~a rendering <output>~a\n" (timestamp-string) site-path)
165+
(call-with-output-file*
166+
#:exists 'truncate/replace
167+
(reroot-path site-path output-dir)
168+
(λ (out)
169+
(for ([post (in-list posts)])
170+
(displayln (full-url (rendered-post-path post)) out)))))
171+
162172
(define (build-all)
163173
(make-directory* build-dir)
164174
(make-directory* output-dir)
@@ -185,7 +195,9 @@
185195
(for ([posts (in-slice num-posts-per-page posts)]
186196
[page-number (in-naturals 1)])
187197
(build-index-page total-pages page-number posts #:tag tag))
188-
(build-feeds posts #:tag tag)))
198+
(build-feeds posts #:tag tag))
199+
200+
(build-sitemap all-posts))
189201

190202
(module+ main
191203
(build-all))

0 commit comments

Comments
 (0)