diff --git a/render.rkt b/render.rkt index 2b348f2..0ac1803 100644 --- a/render.rkt +++ b/render.rkt @@ -114,10 +114,12 @@ (with-output-to-string (λ () (display "") (display-xexpr document))))) -(define (compile-index-scss) +(define (compile-index-scss index.scss) (define scss-files (append mathml:scss-files syntax:scss-files)) (define top-level-style - (string-join (map (λ (x) (format "@import \"~a\";" (path->string x))) scss-files) "\n")) + (string-join + (cons index.scss (map (λ (x) (format "@import \"~a\";" (path->string x))) scss-files)) + "\n")) (sass:compile/string top-level-style #t)) (module+ main @@ -125,8 +127,8 @@ (command-line #:program "meow" #:args (infile outfile) - (define-rule (scss [out "index.css"]) - (~> (compile-index-scss) (write-string out))) + (define-rule (scss [out "index.css"] [in "index.scss"]) + (~> (compile-index-scss (port->string in)) (write-string out))) (define-rule (render [out outfile] [in infile]) (~> (read-input-doc in) input-doc->ir-doc ir-doc->page (write-string out))) (generate/execute (list render scss)))) diff --git a/templates/include.html.rkt b/templates/include.html.rkt new file mode 100644 index 0000000..97b0ea6 --- /dev/null +++ b/templates/include.html.rkt @@ -0,0 +1,5 @@ +#lang s-exp "../xtemplate.rkt" + +`(p () + "this was included from another file #uwu the summary is: " + ,(or (metadata-ref+ metadata 'summary) "no summary :(")) diff --git a/templates/page.html.rkt b/templates/page.html.rkt index f69672a..e59b567 100644 --- a/templates/page.html.rkt +++ b/templates/page.html.rkt @@ -31,7 +31,8 @@ ,content-toc) (main () - ,@content) + ,@content + ,(include "include.html.rkt")) ;; mathjax polyfill script sentinel -- gets replaced by a script tag for crying doge chrombe ;; and with nothing for swole firefox (div ([style "display: none"]) "__X_MATHJAX_POLYFILL_PLACEHOLDER__"))) diff --git a/xtemplate.rkt b/xtemplate.rkt index f81fd1f..b7183ea 100644 --- a/xtemplate.rkt +++ b/xtemplate.rkt @@ -1,12 +1,14 @@ #lang racket/base -(require racket/base racket/format racket/list racket/match racket/string +(require racket/base racket/format racket/list racket/match racket/runtime-path racket/string + racket/splicing "defs.rkt" "util.rkt" syntax/parse syntax/parse/define racket/stxparam (for-syntax racket/base racket/match racket/set)) (provide (rename-out [x:#%module-begin #%module-begin] - [x:#%top #%top]) + [x:#%top #%top] + [x:include include]) (except-out (all-from-out racket/base racket/format racket/list racket/match racket/string "defs.rkt" "util.rkt") #%module-begin #%top)) @@ -20,6 +22,13 @@ (syntax->datum #'id))] (hash-ref tem 'id)) +(define-syntax-parse-rule (x:include what:string) + #:with tem:id (syntax-parameter-value #'template-id) + #:with execute-temp:id (car (generate-temporaries '(included-execute))) + #:with execute-fn + (syntax-local-lift-require #`(rename what execute-temp execute) #'execute-temp) + (execute-fn tem)) + (define-syntax-parse-rule (x:#%module-begin body) (#%module-begin (provide execute required-keys)