Improve
This commit is contained in:
parent
baf24e7cfd
commit
c13a47f2c4
4 changed files with 18 additions and 7 deletions
src
|
@ -1,6 +1,7 @@
|
|||
(defpackage #:hp/config/asset
|
||||
(:use #:cl)
|
||||
(:export #:*asset-roots*))
|
||||
(:export #:*asset-roots*
|
||||
#:*hx-ext*))
|
||||
(in-package #:hp/config/asset)
|
||||
|
||||
(defparameter *asset-roots*
|
||||
|
@ -10,3 +11,6 @@
|
|||
:vendor "/vendor/"
|
||||
:htmx-ext "/vendor/htmx-ext/"
|
||||
:alpine-ext "/vendor/alpine-ext/"))
|
||||
|
||||
(defparameter *hx-ext*
|
||||
"head-support,alpine-morph")
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
(:export #:*assets-server*))
|
||||
(in-package #:hp/middlewares/assets-server)
|
||||
|
||||
(defun exist-public-file-p (path)
|
||||
(defun exist-asset-file-p (path)
|
||||
(let ((pathname (probe-file (concatenate 'string "assets" path))))
|
||||
(and pathname (pathname-name pathname))))
|
||||
|
||||
|
@ -14,5 +14,5 @@
|
|||
(funcall *lack-middleware-static*
|
||||
app
|
||||
:path (lambda (path)
|
||||
(and (exist-public-file-p path) path))
|
||||
(and (exist-asset-file-p path) path))
|
||||
:root (asdf:system-relative-pathname :hp "assets/"))))
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
(defpackage #:hp/view/components/layout/main
|
||||
(:use #:cl)
|
||||
(:local-nicknames (#:pi #:piccolo))
|
||||
(:local-nicknames (#:cfg #:hp/config/asset))
|
||||
(:export #:layout))
|
||||
(in-package #:hp/view/components/layout/main)
|
||||
|
||||
(pi:define-element layout ()
|
||||
(pi:h
|
||||
(body
|
||||
:hx-ext "head-support,alpine-morph"
|
||||
:hx-ext cfg:*hx-ext*
|
||||
:x-data t
|
||||
:|:data-dark| "$store.darkMode.on"
|
||||
; header
|
||||
|
|
|
@ -2,18 +2,24 @@
|
|||
(:use #:cl)
|
||||
(:local-nicknames (#:jg #:jingle))
|
||||
(:local-nicknames (#:pi #:piccolo))
|
||||
(:local-nicknames (#:cfg #:hp/config/env))
|
||||
(:local-nicknames (#:cmp #:hp/view/components/**/*))
|
||||
(:export #:render
|
||||
#:partial-render))
|
||||
(in-package #:hp/view/renderer)
|
||||
|
||||
(defun renderer ()
|
||||
(if (cfg:dev-mode-p)
|
||||
#'pi:element-string
|
||||
#'pi:elem-str))
|
||||
|
||||
(defun render (page &key status metadata)
|
||||
(jg:with-html-response
|
||||
(if status (jg:set-response-status status))
|
||||
(pi:elem-str (cmp:document :metadata metadata
|
||||
(cmp:layout page)))))
|
||||
(funcall (renderer) (cmp:document :metadata metadata
|
||||
(cmp:layout page)))))
|
||||
|
||||
(defun partial-render (component &key status)
|
||||
(jg:with-html-response
|
||||
(if status (jg:set-response-status status))
|
||||
(pi:elem-str (cmp:partial-document component))))
|
||||
(funcall (renderer) (cmp:partial-document component))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue