dev.metalisp.sbt/src/main.lisp

38 lines
1.4 KiB
Common Lisp
Raw Normal View History

2023-06-29 17:19:12 +02:00
(defpackage cl-sbt
2023-07-01 16:30:10 +02:00
(:use :cl)
(:export
2023-08-25 15:10:01 +02:00
:write-html-to-file
2023-07-16 13:57:42 +02:00
:with-page))
2023-07-01 16:30:10 +02:00
2023-06-29 17:19:12 +02:00
(in-package :cl-sbt)
2023-07-03 14:43:58 +02:00
2023-07-22 13:58:46 +02:00
(setq spinneret:*fill-column* 120)
(defparameter *cdn-css* "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css")
(defparameter *cdn-js* "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js")
2023-08-09 14:12:34 +02:00
(defmacro with-page ((&key (author "") (description "") (cdn t) (pagetitle "")) &body body)
2023-07-16 13:57:42 +02:00
`(spinneret:with-html
(:doctype)
(:html
(:head
(:meta :charset "utf-8")
(:meta :name "viewport" :content "width=device-width, initial-scale=1")
2023-08-09 14:12:34 +02:00
(:meta :name "author" :content ,author)
(:meta :name "description" :content ,description)
(:title ,pagetitle)
(if ,cdn
(:link :type "text/css" :rel "stylesheet" :href ,*cdn-css*)
(:link :type "text/css" :rel "stylesheet" :href "5.3.0/bootstrap.min.css")))
2023-08-25 11:09:35 +02:00
(:body (:h1 ,pagetitle)
(:main ,@body))
(if ,cdn
(:script :src *cdn-js*)
(:script :src "5.3.0/bootstrap.bundle.min.js")))))
2023-07-16 13:57:42 +02:00
2023-08-25 15:10:01 +02:00
(defun write-html-to-file (filename string &key (lang "en") (style :tree) (fc 120))
(let ((spinneret:*html-lang* lang)
(spinneret:*html-style* style)
(spinneret:*fill-column* fc))
(with-open-file (stream filename :direction :output :if-exists :supersede)
(write-string string stream))))