diff options
| author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2024-05-13 03:16:10 +0200 |
|---|---|---|
| committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2025-06-15 01:30:29 +0200 |
| commit | 0dd9021d361714db26ec2cb471ff8bbb33a0e800 (patch) | |
| tree | 974eaad3cde5a9de667047dc4a7da19648798902 | |
| parent | 0a34848fee0f124aecc9f4b969f608157a67d147 (diff) | |
| download | haunt-blog-0dd9021d361714db26ec2cb471ff8bbb33a0e800.tar.gz haunt-blog-0dd9021d361714db26ec2cb471ff8bbb33a0e800.tar.bz2 haunt-blog-0dd9021d361714db26ec2cb471ff8bbb33a0e800.zip | |
search: simplify page.
With make-page we can simply create pages and include them in the
builders. We then pass the page content to the layout and it works.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
| -rw-r--r-- | haunt.scm | 2 | ||||
| -rw-r--r-- | website/builders/replicant-blog-search.scm | 45 |
2 files changed, 8 insertions, 39 deletions
@@ -31,7 +31,7 @@ #:posts-directory "markdown" #:readers (list wordpress-markdown-reader) #:builders (list (replicant-blog-website) - (replicant-blog-search-page) + replicant-blog-search-page (static-directory "static") ;;;;;;;;;;; ;; Feeds ;; diff --git a/website/builders/replicant-blog-search.scm b/website/builders/replicant-blog-search.scm index dfbf4c8..1d71cd4 100644 --- a/website/builders/replicant-blog-search.scm +++ b/website/builders/replicant-blog-search.scm @@ -24,6 +24,7 @@ #:use-module (haunt artifact) #:use-module (haunt builder assets) #:use-module (haunt html) + #:use-module (haunt page) #:use-module (haunt post) #:use-module (haunt site) #:use-module (haunt utils) @@ -41,11 +42,7 @@ (@ (href ,(string-append "https://packages.guix.gnu.org/packages/" name))) ,name)) -(define (replicant-blog-search-template site title posts prefix) - (define (post-uri post) - (string-append (or prefix "") "/" - (site-post-slug site post) ".html")) - +(define replicant-blog-search-page-content `((h1 (@ (id "title")) "Search") (p "This blog has no built-in search functionality. Instead users are @@ -71,36 +68,8 @@ FOSDEM in the blog articles, you can use the following commands:") "\"Full text\" search as by default these file managers usually only " "search the file names only.")))) -(define replicant-blog-search-theme - (theme #:name "Replicant" - #:layout replicant-layout - #:post-template replicant-default-post-template - #:collection-template replicant-blog-search-template)) - -(define* (replicant-blog-search-page #:key (theme replicant-blog-search-theme) prefix - (collections - `(("" "search.html" ,posts/reverse-chronological)))) - "Return a procedure that transforms a list of posts into pages -decorated by THEME, whose URLs start with PREFIX." - (define (make-file-name base-name) - (if prefix - (string-append prefix "/" base-name) - base-name)) - - (lambda (site posts) - (define (post->page post) - (let ((base-name (string-append (site-post-slug site post) - ".html"))) - (serialized-artifact (make-file-name base-name) - (render-post theme site post) - sxml->html))) - - (define collection->page - (match-lambda - ((title file-name filter) - (serialized-artifact (make-file-name file-name) - (render-collection theme site title (filter posts) prefix) - sxml->html)))) - - (append (map post->page posts) - (map collection->page collections)))) +(define (replicant-blog-search-page site posts) + (make-page + "search.html" + (replicant-layout site "Blog: Search" replicant-blog-search-page-content) + sxml->html)) |
