grug.scm (2885B)
1 (use-modules (grug site) 2 (grug builders) 3 (grug publishers) 4 (srfi srfi-19)) 5 6 (define (stylesheet name) 7 `(link (@ (rel "stylesheet") 8 (href ,(string-append "/css/" name ".css"))))) 9 10 (define (link name uri) 11 `(a (@ (href ,uri)) ,name)) 12 13 (define (hspan contents) 14 `(span (@ (class "hidden")) ,contents)) 15 16 (define (hhr) 17 `(hr (@ (class "hidden")))) 18 19 (define (blog-template site-metadata metadata body) 20 `(*TOP* 21 (*DECL* DOCTYPE html) 22 (head 23 (meta (@ (harset "utf-8"))) 24 (meta (@ (name "viewport") 25 (content "width=device-width, initial-scale=1"))) 26 (title ,(string-append (assoc-ref metadata 'title) 27 " - " 28 (assoc-ref site-metadata 'title))) 29 ,(stylesheet "style")) 30 (body 31 (div (@ (id "header")) 32 (a (@ (id "headerLink") 33 (href "/")) 34 ,(assoc-ref site-metadata 'title)) 35 ,(hspan " - ") 36 (span (@ (id "headerSubtitle")) 37 ,(assoc-ref site-metadata 'subtitle))) 38 ,(hhr) 39 (nav 40 ,(link "Home" "/") 41 ,(hspan " | ") 42 ,(link "Setup(s)" "/setups.html") 43 ,(hspan " | ") 44 ,(link "About" "/about.html")) 45 ,(hhr) 46 (div (@ (id "content")) 47 ,@body) 48 ,(hhr) 49 (footer 50 (p "Copyright 2025 Luke Willis"))))) 51 52 (define (blog-collection-template posts) 53 `((h1 "Recent Posts") 54 ,@(map 55 (lambda (post) 56 `(article (h2 (a (@ (href ,(assoc-ref post 'uri))) 57 ,(assoc-ref post 'title))) 58 ;; Parse ISO 8601 date from 'date and reformat it to look nice 59 (p (@ (class "date")) 60 ,(date->string 61 (string->date (assoc-ref post 'date) "~Y~m~d") "~B ~d, ~Y")))) 62 (sort posts 63 (lambda (a b) 64 (string>? (assoc-ref a 'date) 65 (assoc-ref b 'date))))))) 66 67 (site #:metadata `((title . "Luke Willis") 68 (subtitle . "Orthodox Christian Technology")) 69 #:builders (list (simple-pages 70 "pages" 71 #:template blog-template) 72 (blog 73 "posts" 74 #:template blog-template 75 #:collection-template blog-collection-template) 76 (copy-directory 77 "css") 78 (copy-directory 79 "img")) 80 #:publishers (list (rsync-publisher #:user "lukejw" 81 #:host "loquat.dev" 82 #:destination "/var/www/htdocs/www.loquat.dev/" 83 #:flags (cons "--rsync-path=openrsync" 84 %default-rsync-flags))))