Use local vars in with-page

This commit is contained in:
Marcus Kammer 2024-12-02 16:55:09 +01:00
parent b074548660
commit 5cc01e31b8

View file

@ -77,10 +77,6 @@
"bootstrap.bundle.min.js")
"Constructs path for HTML to load local bootstrap js from disk.")
(defparameter *color-theme* "light")
(defparameter *print-css-url* nil)
(defun bs-url-css ()
(if *use-cdn*
*cdn-url-css*
@ -124,7 +120,10 @@
(defmacro with-page ((&key
title
(lang "en")
(color-theme "light")
meta
print-css-url
add-css-urls
add-js-urls)
&body body)
@ -144,7 +143,8 @@ Example usage:
(with-page (:meta (:author \"John Doe\") :title \"My Page\" :main-con t) \"foo\")"
`(spinneret:with-html-string
(:doctype)
(:html :data-bs-theme ,*color-theme*
(:html :lang ,lang
:data-bs-theme ,color-theme
(:head (:meta :charset "utf-8")
(:meta :name "viewport"
:content "width=device-width, initial-scale=1")
@ -158,8 +158,8 @@ Example usage:
(:title ,title)
(:style (:raw "@media print{.navbar,.nav,.btn,.carousel,.dropdown-menu,footer,.no-print{display:none!important}.container,.container-fluid{width:100%!important;padding:0!important;margin:0!important}[class^=\"col-\"]{width:100%!important;flex:0 0 100%!important;max-width:100%!important}body{font-size:12pt;line-height:1.5}h1,.h1{font-size:24pt}h2,.h2{font-size:22pt}h3,.h3{font-size:20pt}h4,.h4{font-size:18pt}h5,.h5{font-size:16pt}h6,.h6{font-size:14pt}h1,h2,h3,h4,h5,h6,p,img,table,figure{page-break-inside:avoid}a{text-decoration:underline;color:#000!important}a[href^=\"http\"]:after{content:\" (\" attr(href) \")\";font-size:80%}.table-responsive{overflow:visible!important}.card{border:none!important;box-shadow:none!important}@page{margin:1in}}"))
(when *print-css-url* (:link :type "text/css" :rel "stylesheet" :href ,*print-css-url*))
(:link :type "text/css" :rel "stylesheet" :href ,(bs-url-css))
(when ,print-css-url (:link :type "text/css" :rel "stylesheet" :href ,print-css-url))
(:link :type "text/css" :rel "stylesheet" :href (bs-url-css))
,@(loop for url in add-css-urls
collect `(:link :type "text/css"
:rel "stylesheet" :href ,url))
@ -168,7 +168,7 @@ Example usage:
(:body ,@body)
(:script :src ,(bs-url-js))
(:script :src (bs-url-js))
,@(loop for url in add-js-urls
collect `(:script :src ,url)))))