website/src/components/document/styles.lisp

35 lines
1.2 KiB
Common Lisp
Raw Normal View History

2024-04-25 16:50:08 +09:00
(defpackage #:hp/components/document/styles
2024-04-22 06:37:20 +09:00
(:use #:cl)
(:local-nicknames (#:pi #:piccolo))
(:import-from #:hp/view/asset
2024-04-24 00:09:04 +09:00
#:defasset
2024-04-22 06:37:20 +09:00
#:get-css-paths)
2024-04-22 15:00:33 +09:00
(:export #:on-demand-styles
#:styles))
2024-04-25 16:50:08 +09:00
(in-package #:hp/components/document/styles)
2024-04-22 06:37:20 +09:00
2024-04-24 00:39:08 +09:00
(defasset *ress* :vendor "ress@5.0.2.css")
(defasset *global* :css "global.css")
2024-04-22 06:37:20 +09:00
2024-04-22 15:00:33 +09:00
(pi:define-element on-demand-styles ()
2024-04-24 00:39:08 +09:00
(let* ((html-str (let ((pi:*escape-html* nil))
(pi:elem-str pi:children)))
2024-04-22 06:37:20 +09:00
(css-paths (get-css-paths html-str)))
(pi:h
(<>
(mapcar (lambda (path)
(link :rel "stylesheet" :type "text/css" :href path))
css-paths)))))
2024-04-22 15:00:33 +09:00
(pi:define-element styles ()
2024-04-22 06:37:20 +09:00
(pi:h
(<>
(link :rel "stylesheet" :type "text/css" :href *ress*)
2024-04-24 00:39:08 +09:00
(link :rel "stylesheet" :type "text/css" :href *global*)
2024-04-22 15:00:33 +09:00
(on-demand-styles pi:children)
2024-04-22 06:37:20 +09:00
(link :rel "preconnect" :href "https://fonts.googleapis.com")
(link :rel "preconnect" :href "https://fonts.gstatic.com" :crossorigin t)
2024-04-24 00:39:08 +09:00
(link
2024-04-22 06:37:20 +09:00
:rel "stylesheet"
:href "https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap"))))