aboutsummaryrefslogtreecommitdiff
path: root/haunt/jakob/utils/pagination.scm
diff options
context:
space:
mode:
Diffstat (limited to 'haunt/jakob/utils/pagination.scm')
-rw-r--r--haunt/jakob/utils/pagination.scm22
1 files changed, 17 insertions, 5 deletions
diff --git a/haunt/jakob/utils/pagination.scm b/haunt/jakob/utils/pagination.scm
index 68959a3..f869897 100644
--- a/haunt/jakob/utils/pagination.scm
+++ b/haunt/jakob/utils/pagination.scm
@@ -59,20 +59,30 @@ lists of the form (index, items)."
;;; Rendering.
;;;
-(define (render-listing content title previous-page next-page)
+(define* (render-listing content title previous-page next-page
+ #:key enable-search)
"Return an SHTML document showing CONTENT, with the header TITLE and links to
PREVIOUS-PAGE and NEXT-PAGE."
#<((h1 ,title)
+ ,@(if enable-search
+ '((div (@ (id "search"))))
+ '())
,@content
(nav
(@ (id "pagination"))
,(when previous-page
(hyperlink previous-page "← Previous Page"))
,(when next-page
- (hyperlink next-page "Next Page →")))))
+ (hyperlink next-page "Next Page →")))
+ ,@(if enable-search
+ `((link (@ (rel "stylesheet")
+ (href "/_pagefind/pagefind-ui.css")))
+ (script (@ (src "/_pagefind/pagefind-ui.js")))
+ (script "window.addEventListener('DOMContentLoaded', function (event) { return new PagefindUI({ element: '#search' }); })"))
+ '())))
(define* (items->pages render-item items base-title base-file-name
- #:key (items-per-page %items-per-page))
+ #:key enable-search (items-per-page %items-per-page))
"Return a list of Haunt pages for ITEMS with no more than ITEMS-PER-PAGE items
to a page, with headers containing BASE-TITLE and output file names beginning
with BASE-FILE-NAME. RENDER-ITEM is a procedure returning a SXML rendering of
@@ -92,11 +102,13 @@ the item from ITEMS passed as a parameter."
(next-page (if (<= (1+ index) (ceiling/ (length items)
%items-per-page))
(index->file-name (1+ index))
- #f)))
+ #f))
+ (enable-search (and enable-search (= index 1))))
(make-page (index->file-name index)
(theme #:title title
#:content
(render-listing (map render-item subset) title
- previous-page next-page))
+ previous-page next-page
+ #:enable-search enable-search))
sxml->html))))
(paginate items)))

© 2015 - 2026 Jakob L. Kreuze