aboutsummaryrefslogtreecommitdiff
path: root/haunt/jakob
diff options
context:
space:
mode:
authorJakob L. Kreuze2023-08-04 20:08:07 -0400
committerJakob L. Kreuze2023-08-04 20:08:07 -0400
commit78a88bcb9096f0622d23c64064128f440f53b704 (patch)
treef796b87e9eb075bc1ada475ae358fbda3409135f /haunt/jakob
parentcd852b2ec09927dd0f776504ab071a9e60bb3fb2 (diff)
Enable building the site offline
Diffstat (limited to 'haunt/jakob')
-rw-r--r--haunt/jakob/utils/comments.scm38
1 files changed, 21 insertions, 17 deletions
diff --git a/haunt/jakob/utils/comments.scm b/haunt/jakob/utils/comments.scm
index e41fe2c..f38bb18 100644
--- a/haunt/jakob/utils/comments.scm
+++ b/haunt/jakob/utils/comments.scm
@@ -223,25 +223,29 @@
(define (fetch-comments slug)
"Blocking call to webmention.io to retrieve a vector of all Webmentions for `slug'"
- (let ((url (format #f "https://jakob.space/api/comments?p=~a" slug)))
- (receive (response-status response-body)
- (http-request url)
- (chain response-body
- (bytevector->string _ "UTF-8")
- (json-string->scm _)
- (vector->list _)
- (map scm->json-string _)
- (map (lambda (x) (call-with-input-string x json->internal-comment)) _)))))
+ (if (getenv "HAUNT_SKIP_COMMENTS")
+ '()
+ (let ((url (format #f "https://jakob.space/api/comments?p=~a" slug)))
+ (receive (response-status response-body)
+ (http-request url)
+ (chain response-body
+ (bytevector->string _ "UTF-8")
+ (json-string->scm _)
+ (vector->list _)
+ (map scm->json-string _)
+ (map (lambda (x) (call-with-input-string x json->internal-comment)) _))))))
(define (fetch-webmentions slug)
"Blocking call to webmention.io to retrieve a vector of all Webmentions for `slug'"
(define prefixes '("http://jakob.space/" "https://jakob.space/"
"http://jakob.space/blog/" "https://jakob.space/blog/"))
- (let* ((target-queries (map (lambda (pre)
- (format #f "target[]=~a~a.html" pre slug))
- prefixes))
- (url (format #f "https://webmention.io/api/mentions.jf2?per-page=200&page=0&~a"
- (string-join target-queries "&"))))
- (receive (response-status response-body)
- (http-request url)
- (call-with-input-string (bytevector->string response-body "UTF-8") json->scm))))
+ (if (getenv "HAUNT_SKIP_COMMENTS")
+ `(("children" . #()))
+ (let* ((target-queries (map (lambda (pre)
+ (format #f "target[]=~a~a.html" pre slug))
+ prefixes))
+ (url (format #f "https://webmention.io/api/mentions.jf2?per-page=200&page=0&~a"
+ (string-join target-queries "&"))))
+ (receive (response-status response-body)
+ (http-request url)
+ (call-with-input-string (bytevector->string response-body "UTF-8") json->scm)))))

© 2015 - 2026 Jakob L. Kreuze