diff options
| author | Jakob L. Kreuze | 2023-08-04 20:08:07 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2023-08-04 20:08:07 -0400 |
| commit | 78a88bcb9096f0622d23c64064128f440f53b704 (patch) | |
| tree | f796b87e9eb075bc1ada475ae358fbda3409135f /haunt/jakob | |
| parent | cd852b2ec09927dd0f776504ab071a9e60bb3fb2 (diff) | |
Enable building the site offline
Diffstat (limited to 'haunt/jakob')
| -rw-r--r-- | haunt/jakob/utils/comments.scm | 38 |
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))))) |