Compare commits

...

2 commits

Author SHA1 Message Date
688ef6dc18
Add contents to works page 2025-05-18 11:05:02 +09:00
fd28b11c00
Rename work to works 2025-05-18 08:12:43 +09:00
7 changed files with 44 additions and 27 deletions

View file

@ -7,7 +7,7 @@
(defparameter *nav-menu*
'(("/about" "about")
("/work" "work")
("/works" "works")
("/blog" "blog")))
(defcomp ~pc-header ()

View file

@ -9,7 +9,7 @@
#:microcms-service-domain
#:microcms-api-key)
(:export #:get-about
#:get-work
#:get-works
#:get-blog-list
#:get-blog-detail))
(in-package #:website/lib/cms)
@ -27,8 +27,8 @@
(define-object-client about)
(memorize get-about)
(define-object-client work)
(memorize get-work)
(define-object-client works)
(memorize get-works)
(define-list-client blog)
(memorize get-blog-list)

View file

@ -16,7 +16,9 @@
(defmethod jingle:process-response :around ((app jingle:app) result)
(when (eq (request-method *request*) :get)
(set-response-header :cache-control "public, max-age=60"))
(if (context :no-cache)
(set-response-header :cache-control "private, no-store, must-revalidate")
(set-response-header :cache-control "public, max-age=60")))
(cond ((api-request-p)
(set-response-header :content-type "application/json; charset=utf-8")
(call-next-method app (to-json result)))

View file

@ -17,13 +17,14 @@
(defun handle-get (params)
(setf (context :metadata) *metadata*)
(with-request-params ((draft-key "draft-key" nil)) params
(setf (context :no-cache) draft-key)
(let ((about (get-about :query (list :draft-key draft-key))))
(hsx
(<>
(and draft-key (hsx (p :class "text-lg text-pink-500" "下書きモード")))
(article :class "prose max-w-none"
(h1 "About")
(div :class "flex justify-center"
(div :class "flex justify-center"
(figure :class "flex flex-col items-center"
(img
:src (accesses about :avatar :url)

View file

@ -8,7 +8,8 @@
(:import-from #:website/helper
#:get-request-body-plist)
(:import-from #:website/lib/cms
#:get-about)
#:get-about
#:get-works)
(:export #:handle-post))
(in-package #:website/routes/api/revalidate)
@ -20,5 +21,6 @@
(return-from handle-post '(:|message| "Invalid token")))
(let* ((body (get-request-body-plist))
(api (getf body :|api|)))
(cond ((string= api "about") (clear-cache 'get-about)))
(cond ((string= api "about") (clear-cache 'get-about))
((string= api "works") (clear-cache 'get-works)))
'(:|message| "ok")))

View file

@ -1,19 +0,0 @@
(defpackage #:website/routes/work
(:use #:cl
#:hsx
#:jingle)
(:import-from #:website/lib/cms
#:get-work)
(:import-from #:website/lib/time
#:datetime
#:jp-datetime)
(:export #:handle-get))
(in-package #:website/routes/work)
(defparameter *metadata*
(list :title "work"))
(defun handle-get (params)
(declare (ignore params))
(setf (context :metadata) *metadata*)
(hsx (p "coming soon")))

31
src/routes/works.lisp Normal file
View file

@ -0,0 +1,31 @@
(defpackage #:website/routes/works
(:use #:cl
#:hsx
#:jingle)
(:import-from #:website/lib/cms
#:get-works)
(:import-from #:website/lib/time
#:datetime
#:jp-datetime)
(:export #:handle-get))
(in-package #:website/routes/works)
(defparameter *metadata*
(list :title "works"))
(defun handle-get (params)
(setf (context :metadata) *metadata*)
(with-request-params ((draft-key "draft-key" nil)) params
(setf (context :no-cache) draft-key)
(let ((works (get-works :query (list :draft-key draft-key))))
(hsx
(<>
(and draft-key (hsx (p :class "text-lg text-pink-500" "下書きモード")))
(article :class "prose max-w-none"
(h1 "Works")
(raw! (getf works :content))
(p :class "text-right"
"(最終更新:"
(|time| :datetime (datetime (getf works :revised-at))
(jp-datetime (getf works :revised-at)))
"")))))))