(define-module (operationnull theme) #:use-module (haunt artifact) #:use-module (haunt builder blog) #:use-module (haunt html) #:use-module (haunt post) #:use-module (haunt site) #:use-module (ice-9 match) #:use-module (srfi srfi-19) #:export (main-theme)) (define %cc-by-sa-link '(a (@ (href "https://creativecommons.org/licenses/by-sa/4.0/")) "CC-BY-SA 4.0")) (define (first-paragraph post) (let loop ((sxml (post-sxml post))) (match sxml (() '()) (((and paragraph ('p . _)) . _) (list paragraph)) ((head . tail) (cons head (loop tail)))))) (define (stylesheet name) `(link (@ (rel "stylesheet") (href ,(string-append "/assets/" name ".css"))))) (define main-theme (theme #:name "bdunahu" #:layout (lambda (site title body) `((doctype "html") (head (meta (@ (charset "utf-8"))) (meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) (link (@ (rel "icon") (type "image/x-icon") (href "/assets/favicon.ico"))) (title ,(string-append title " — " (site-title site))) (link (@ (rel "alternate") (type "application/atom+xml") (title "Atom feed") (href "/feed.xml"))) ,(stylesheet "site") ) (body (intro '(div (@ (class "container")) (img (@ (alt "raven") (class "no-border") (src "/assets/raven.png"))) (h1 (span (@ (class "white")) bdunahu)) (p "cs graduate student @ " (a (@ (href "https://www.cics.umass.edu/")) "UMass Amherst")))) (nav '(div (@ (class "container")) (ul (li (a (@ (href "https://git.operationnull.com/")) "git")) (li (a (@ (href "/pages/contact.html")) "contact")) (li (a (@ (href "/posts/")) "rand")) (li (a (@ (href "/")) "home"))))) ,body (footer (@ (class "footer")) "Copyright © 2024 bdunahu" (br) "Site content available under the " ,%cc-by-sa-link " license " (a (@ (href "https://git.operationnull.com/operationnull.git/")) "here") "." (br) "Last updated on " ,(date->string (current-date) "~b ~d, ~Y") ". Generated with " (a (@ (href "https://dthompson.us/projects/haunt.html")) "Haunt") " and " (a (@ (href "https://gnu.org/software/guile")) "Guile Scheme") ".")))) #:post-template (lambda (post) `((article (h3 (@ (class "title")),(post-ref post 'title)) (div (@ (class "date")) ,(date->string (post-date post) "~B ~d, ~Y")) (div (@ (class "post")) ,(post-sxml post))))) #:collection-template (lambda (site title posts prefix) (define (post-uri post) (string-append prefix "/" (site-post-slug site post) ".html")) `(article (h2 ,title (a (@ (href "/feed.xml")) (img (@ (class "feed-icon") (src "/assets/feed.png"))))) ,(map (lambda (post) (let ((uri (post-uri post))) `(article (@ (class "summary")) (h3 (a (@ (href ,uri)) ,(post-ref post 'title))) (div (@ (class "date")) ,(date->string (post-date post) "~B ~d, ~Y")) (div (@ (class "post")) ,(first-paragraph post)) (a (@ (href ,uri)) "more...")))) posts))) #:pagination-template (lambda (site body previous-page next-page) `(,@body (div (@ (class "paginator")) ,(if previous-page `(a (@ (class "paginator-prev") (href ,previous-page)) "← Newer") '()) ,(if next-page `(a (@ (class "paginator-next") (href ,next-page)) "Older →") '())))) ))