Fix white archive page.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Oliver 2026-11-24 13:33:30 +00:00
parent d5a96e3190
commit 2143e966c9
4 changed files with 25 additions and 10 deletions

View File

@ -10,7 +10,8 @@
:refer [state load-index! latest-article org->document]]
[com.oly.static-sites.do-blog.pages.chess-board :as chess]
[com.oly.static-sites.do-blog.pages.chess.state :as chess-state]
[com.oly.static-sites.do-blog.pages.chess.vstate :as viking-state])
[com.oly.static-sites.do-blog.pages.chess.vstate :as viking-state]
[com.oly.static-sites.do-blog.pages.matrix-widget :as widget])
(:require-macros [cl-eorg.macros :refer [org-doc->move-process]]))
;; Copy org documents into public/ and write org-meta-index.edn at compile time.
@ -40,6 +41,8 @@
(defn handle-action [[action & args]]
(case action
:search/set-terms (swap! state assoc-in [:search :terms] (first args))
:widget/set-draft (swap! widget/widget-state assoc :draft (first args))
:widget/send (widget/send-message! (:draft @widget/widget-state))
(js/console.warn "Unknown action" (pr-str action))))
(defn dispatch [{:replicant/keys [dom-event]} actions]
@ -47,12 +50,14 @@
;; Navigation
(defn fetch-text [path on-success on-error]
(defn fetch-text
([path on-success] (fetch-text path on-success nil))
([path on-success on-error]
(GET path {:response-format (text-response-format)
:handler on-success
:error-handler (fn [error]
(js/console.error "Failed to fetch" path (clj->js error))
(on-error error))}))
(when on-error (on-error error)))})))
(defn show-route! [match & {:as extra}]
(swap! state merge
@ -97,6 +102,7 @@
(add-watch state ::render (fn [_ _ _ _] (render!)))
(add-watch chess-state/game-state ::render (fn [_ _ _ _] (render!)))
(add-watch viking-state/game-state ::render (fn [_ _ _ _] (render!)))
(add-watch widget/widget-state ::render (fn [_ _ _ _] (render!)))
(fetch-text "/documents/org-meta-index.edn"
(fn [response]
(load-index! (reader/read-string response))

View File

@ -11,6 +11,7 @@
["/archive/{*tag}" {:name :archive}]
["/chess/" {:name :chess}]
["/about/" {:name :about}]
["/widget/" {:name :widget}]
["/posts/{*path}" {:name :posts}]])
(def router (rc/router routes))

View File

@ -52,6 +52,7 @@
["/" (page-state "/" (doc latest))]
[(href :about) (page-state (href :about) nil)]
[(href :chess) (page-state (href :chess) nil)]
[(href :widget) (page-state (href :widget) nil)]
[(archive-href "") (page-state (archive-href "") nil)]]
(for [tag tags
:let [url (archive-href tag)]]

View File

@ -25,6 +25,7 @@
:archive (if (str/blank? tag) "Past articles" (str "Articles tagged " tag))
:chess "Chess"
:about "About"
:widget "Matrix widget"
"Page not found"))]
(if (str/blank? title)
site-name
@ -58,6 +59,10 @@
#?(:clj (defmethod page :chess [_state]
[:p.lh-copy "Loading the chess board…"]))
;; Likewise the Matrix widget (pages/matrix_widget.cljs).
#?(:clj (defmethod page :widget [_state]
[:p.pa3.lh-copy "Loading the Matrix widget…"]))
(defn loading-bar [loading]
(when loading
[:div.fixed.top-0.left-0.w-100.bg-green.white.f6.tc.pa1.z-999
@ -126,6 +131,8 @@
(search-articles {:search terms})))]]]))
(defn app [state]
(layout state (if (:not-found? state)
(not-found-page)
(page state))))
(cond
(:not-found? state) (layout state (not-found-page))
;; The widget is embedded in a Matrix client, so it skips the site chrome.
(= :widget (-> state :route :data :name)) (page state)
:else (layout state (page state))))