(declare (module (boudin page style)) (export make-style style page-style style-template site-style style-writer)) (import (boudin page) (boudin site) (scss) (html-parser) (srfi 152) (chicken pathname)) (define (make-style . rules) (make-page rules (make-pathname (site-output) "style.css") (style-template) (style-writer) '())) (define (style props) ;; sxml: `(el (@ ,(style '((padding 3em) (color red)))) content ...) (let ((sty (scss->css `(css+ (_ ,@props))))) (list 'style (substring sty 4 (- (string-length sty) 2))))) (define (page-style . rules) ;; sxml: `(html (head ,(page-style '(body (margin auto))))) `(style ,(scss->css `(css+ ,@rules)))) (define style-template (make-parameter (lambda (pg) `(css+ ,@(page-content pg))))) (define site-style (make-parameter '((body (font 18px/1.4 sans-serif) (max-width 70ch) (padding 2ch) (margin 0 auto))))) (define style-writer (make-parameter write-css))