Move components
This commit is contained in:
parent
b40471bde2
commit
0f7978cc5c
6 changed files with 14 additions and 14 deletions
src/components/document
30
src/components/document/main.lisp
Normal file
30
src/components/document/main.lisp
Normal file
|
@ -0,0 +1,30 @@
|
|||
(defpackage #:hp/components/document/main
|
||||
(:use #:cl)
|
||||
(:local-nicknames (#:pi #:piccolo))
|
||||
(:import-from #:hp/components/document/styles
|
||||
#:styles
|
||||
#:on-demand-styles)
|
||||
(:import-from #:hp/components/document/scripts
|
||||
#:scripts)
|
||||
(:import-from #:hp/components/document/seo
|
||||
#:seo)
|
||||
(:export #:document
|
||||
#:partial-document))
|
||||
(in-package #:hp/components/document/main)
|
||||
|
||||
(pi:define-element document (metadata)
|
||||
(pi:h
|
||||
(html :lang "ja"
|
||||
(head
|
||||
(meta :charset "UTF-8")
|
||||
(styles pi:children)
|
||||
(scripts)
|
||||
(seo metadata))
|
||||
pi:children)))
|
||||
|
||||
(pi:define-element partial-document ()
|
||||
(pi:h
|
||||
(<>
|
||||
(head :hx-head "append"
|
||||
(on-demand-styles pi:children))
|
||||
pi:children)))
|
36
src/components/document/scripts.lisp
Normal file
36
src/components/document/scripts.lisp
Normal file
|
@ -0,0 +1,36 @@
|
|||
(defpackage #:hp/components/document/scripts
|
||||
(:use #:cl)
|
||||
(:local-nicknames (#:pi #:piccolo))
|
||||
(:import-from #:hp/view/asset
|
||||
#:defasset)
|
||||
(:export #:scripts))
|
||||
(in-package #:hp/components/document/scripts)
|
||||
|
||||
(defasset *htmx* :vendor "htmx@1.9.12.js")
|
||||
(defasset *htmx-exts* :htmx-ext
|
||||
("alpine-morph@1.9.12.js"
|
||||
"head-support@1.9.12.js"))
|
||||
|
||||
(defasset *alpine* :vendor "alpine@3.13.8.js")
|
||||
(defasset *alpine-exts* :alpine-ext
|
||||
("async-alpine@1.2.2.js"
|
||||
"persist@3.13.8.js"
|
||||
"morph@3.13.8.js"))
|
||||
|
||||
(defasset *global* :js "global.js")
|
||||
|
||||
(pi:define-element extentions (paths defer)
|
||||
(pi:h
|
||||
(<>
|
||||
(mapcar (lambda (path)
|
||||
(script :src path :defer defer))
|
||||
paths))))
|
||||
|
||||
(pi:define-element scripts ()
|
||||
(pi:h
|
||||
(<>
|
||||
(script :src *htmx*)
|
||||
(extentions :paths *htmx-exts*)
|
||||
(extentions :paths *alpine-exts* :defer t)
|
||||
(script :src *global* :defer t)
|
||||
(script :src *alpine* :defer t))))
|
13
src/components/document/seo.lisp
Normal file
13
src/components/document/seo.lisp
Normal file
|
@ -0,0 +1,13 @@
|
|||
(defpackage #:hp/components/document/seo
|
||||
(:use #:cl)
|
||||
(:local-nicknames (#:pi #:piccolo))
|
||||
(:export #:seo))
|
||||
(in-package #:hp/components/document/seo)
|
||||
|
||||
(pi:define-element seo (title description)
|
||||
(pi:h
|
||||
(<>
|
||||
(title (format nil "~@[~a - ~]skyizwhite.dev" title))
|
||||
(meta
|
||||
:name "description"
|
||||
:content (or description "pakuの個人サイト")))))
|
34
src/components/document/styles.lisp
Normal file
34
src/components/document/styles.lisp
Normal file
|
@ -0,0 +1,34 @@
|
|||
(defpackage #:hp/components/document/styles
|
||||
(:use #:cl)
|
||||
(:local-nicknames (#:pi #:piccolo))
|
||||
(:import-from #:hp/view/asset
|
||||
#:defasset
|
||||
#:get-css-paths)
|
||||
(:export #:on-demand-styles
|
||||
#:styles))
|
||||
(in-package #:hp/components/document/styles)
|
||||
|
||||
(defasset *ress* :vendor "ress@5.0.2.css")
|
||||
(defasset *global* :css "global.css")
|
||||
|
||||
(pi:define-element on-demand-styles ()
|
||||
(let* ((html-str (let ((pi:*escape-html* nil))
|
||||
(pi:elem-str pi:children)))
|
||||
(css-paths (get-css-paths html-str)))
|
||||
(pi:h
|
||||
(<>
|
||||
(mapcar (lambda (path)
|
||||
(link :rel "stylesheet" :type "text/css" :href path))
|
||||
css-paths)))))
|
||||
|
||||
(pi:define-element styles ()
|
||||
(pi:h
|
||||
(<>
|
||||
(link :rel "stylesheet" :type "text/css" :href *ress*)
|
||||
(link :rel "stylesheet" :type "text/css" :href *global*)
|
||||
(on-demand-styles pi:children)
|
||||
(link :rel "preconnect" :href "https://fonts.googleapis.com")
|
||||
(link :rel "preconnect" :href "https://fonts.gstatic.com" :crossorigin t)
|
||||
(link
|
||||
:rel "stylesheet"
|
||||
:href "https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap"))))
|
Loading…
Add table
Add a link
Reference in a new issue