convert to using replicant in place of reagent.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Oliver 2026-10-20 16:22:50 +01:00
parent c1b081dde8
commit d5a96e3190
14 changed files with 215 additions and 119 deletions

View File

@ -4,7 +4,6 @@
org.clojure/clojurescript {:mvn/version "1.11.60"} org.clojure/clojurescript {:mvn/version "1.11.60"}
no.cjohansen/replicant {:mvn/version "2026.07.1"} no.cjohansen/replicant {:mvn/version "2026.07.1"}
tick/tick {:mvn/version "0.5.0"}
metosin/reitit {:mvn/version "0.5.18"} metosin/reitit {:mvn/version "0.5.18"}
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"} cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}

View File

@ -4,6 +4,7 @@
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Digital Octave</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" />
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.12.0/css/tachyons.min.css" /> <link rel="stylesheet" href="https://unpkg.com/tachyons@4.12.0/css/tachyons.min.css" />
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>

View File

@ -4,8 +4,13 @@
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Page not found · Digital Octave</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css" />
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.12.0/css/tachyons.min.css" /> <link rel="stylesheet" href="https://unpkg.com/tachyons@4.12.0/css/tachyons.min.css" />
<script src="https://cdn.tailwindcss.com"></script>
<style type="text/css">
.font { font-family: "Roboto Slab", serif !important; }
</style>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
#loading { #loading {
-webkit-animation: rotation 2s infinite linear; -webkit-animation: rotation 2s infinite linear;
@ -24,21 +29,11 @@
</head> </head>
<body class="ma0 pa0 h-100"> <body class="ma0 pa0 h-100">
<div id="app" class="ma0 pa0 h-100"> <!-- Everything between the app markers is replaced by the static generator
<section id="startup" class="h-100"> (com.oly.static-sites.do-blog.ssr). -->
<noscript> <div id="app" class="ma0 pa0 h-100"><!--app--><div class="font h-100"><nav class="db dn-l bg-blue pa3"><a href="/" class="white f4 b link db mb2">Digital Octave</a><a href="/" class="black dib mr3 f5 link hover-green">Home</a><a href="/archive/" class="black dib mr3 f5 link hover-green">Past articles</a><a href="/chess/" class="black dib mr3 f5 link hover-green">Chess</a><a href="/about/" class="black dib mr3 f5 link hover-green">About</a></nav><div class="h-100 flex items-stretch"><div style="flex-basis: 20rem; flex-grow: 1;" class="dn db-l pa3 bg-blue"><div><article class="mw5 center bg-white br3 pa3 pa4-ns mv3 ba b--black-10"><div class="tc"><img src="/images/default/me.png" alt="Photo of Oly" class="br-100 h4 w4 dib ba b--black-05 pa2"><h1 class="f3 mb2">Oly</h1><h2 class="f5 fw4 gray mt0">Earthling, Software Engineer</h2></div></article><ul class="list pl0 measure center"><li class="lh-copy pv3 b--black-30 ba bt-0 bl-0 br-0"><a href="/" class="black f3 link hover-green">Home</a></li><li class="lh-copy pv3 b--black-30 ba bt-0 bl-0 br-0"><a href="/archive/" class="black f3 link hover-green">Past articles</a></li><li class="lh-copy pv3 b--black-30 ba bt-0 bl-0 br-0"><a href="/chess/" class="black f3 link hover-green">Chess</a></li><li class="lh-copy pv3 b--black-30 ba bt-0 bl-0 br-0"><a href="/about/" class="black f3 link hover-green">About</a></li></ul></div></div><div style="flex-basis: 0; flex-grow: 999;" class="ma3 pa3"><div><input type="text" placeholder="Search" value class="w-100 center input-reset ba b--black-20 pa2 mb2"></div><div class="measure lh-copy"><h1 class="f2">Page not found</h1><p>Sorry, there is nothing at this address. It may have moved, or the link may be wrong.</p><p><a href="/" class="link blue hover-green">Go to the latest article</a> or <a href="/archive/" class="link blue hover-green">browse past articles</a>.</p></div></div></div></div><!--/app--></div>
You need to enable JavaScript to run this app. <script src="/js/base.js" type="text/javascript"></script>
</noscript> <script src="/js/app.js" type="text/javascript"></script>
<div class="h-100 w-100 flex justify-around items-center v-mid">
<div class="v-mid tc">
<p class="f2 button is-warning is-loading">Initiating Blog</p>
<i id="loading" class="f-6 fas fa-circle-notch"></i>
<p>Application is loading, if nothing happens ensure javascript is enabled.</p>
</div>
</div>
</section>
</div>
<script src="/cljs-out/main.js" type="text/javascript"></script>
</body> </body>
</html> </html>

View File

@ -23,8 +23,9 @@
(defn render! [] (defn render! []
;; Nothing to render until the first route has resolved; until then the ;; Nothing to render until the first route has resolved; until then the
;; static (server generated) HTML stays in place. ;; static (server generated) HTML stays in place.
(when (:route @state) (when-let [current (when (:route @state) @state)]
(r/render (js/document.getElementById "app") (views/app @state)))) (set! js/document.title (views/page-title current))
(r/render (js/document.getElementById "app") (views/app current))))
;; Event handling for data driven handlers, e.g. [[:search/set-terms :event.target/value]] ;; Event handling for data driven handlers, e.g. [[:search/set-terms :event.target/value]]
@ -46,28 +47,47 @@
;; Navigation ;; Navigation
(defn fetch-text [path on-success] (defn fetch-text [path on-success on-error]
(GET path {:response-format (text-response-format) (GET path {:response-format (text-response-format)
:handler on-success :handler on-success
:error-handler #(js/console.error "Failed to fetch" path (clj->js %))})) :error-handler (fn [error]
(js/console.error "Failed to fetch" path (clj->js error))
(on-error error))}))
(defn show-route! [match & {:as extra}] (defn show-route! [match & {:as extra}]
(swap! state merge {:route match :search {:terms ""}} extra)) (swap! state merge
{:route match :search {:terms ""} :loading nil :not-found? false}
extra))
(defn show-document! [match relative-path] (defn show-not-found! [match]
(show-route! (or match {:data {:name :not-found}
:path js/location.pathname})
:document nil
:not-found? true))
(defn show-document!
"Fetch and show an org document. The current page stays visible with a
loading indicator until it arrives; responses for a page we have since
navigated away from are dropped."
[match relative-path]
(if relative-path (if relative-path
(fetch-text (str "/documents/" relative-path) (let [path (:path match)
#(show-route! match :document (org->document %))) current? #(= path (:loading @state))]
(js/console.warn "No document found for" (pr-str (:path match))))) (swap! state assoc :loading path)
(fetch-text (str "/documents/" relative-path)
#(when (current?) (show-route! match :document (org->document %)))
#(when (current?) (show-not-found! match))))
(show-not-found! match)))
(defn on-navigate [raw-match] (defn on-navigate [raw-match]
(when-let [match (normalize-match raw-match)] (if-let [match (normalize-match raw-match)]
(case (-> match :data :name) (case (-> match :data :name)
:homepage (show-document! match (latest-article)) :homepage (show-document! match (latest-article))
:posts (show-document! match (-> match :path-params :path)) :posts (show-document! match (-> match :path-params :path))
:chess (do (chess/start! match) :chess (do (chess/start! match)
(show-route! match)) (show-route! match))
(show-route! match)))) (show-route! match))
(show-not-found! nil)))
(defn ^:dev/after-load reload! [] (defn ^:dev/after-load reload! []
(render!)) (render!))

View File

@ -1,4 +1,28 @@
(ns com.oly.static-sites.do-blog.pages.about) (ns com.oly.static-sites.do-blog.pages.about
(:require [com.oly.static-sites.do-blog.routes :refer [archive-href]]
[com.oly.static-sites.do-blog.pages.helpers.database :refer [search-articles]]
[com.oly.static-sites.do-blog.pages.components.core :refer [pill-grow]]))
(defn top-tags
"The most used tags across all articles, most frequent first."
[articles n]
(->> articles
(mapcat :tags)
(remove #{"draft"})
frequencies
(sort-by (fn [[tag freq]] [(- freq) tag]))
(take n)
(map first)))
(defn about-page [_state] (defn about-page [_state]
[:div "hi2"]) (let [articles (search-articles {})]
[:div.measure.lh-copy
[:h1.f2 "About"]
[:p "Hi, I'm Oly: earthling and software engineer."]
[:p (str "This site collects " (count articles)
" articles: notes, tutorials, reviews and recipes, written in org mode.")]
[:h2.f4 "Popular topics"]
[:div
(for [tag (top-tags articles 12)]
[:span.mr2 {:replicant/key tag}
(pill-grow {:href (archive-href tag) :text tag})])]]))

View File

@ -1,17 +1,18 @@
(ns com.oly.static-sites.do-blog.pages.archive (ns com.oly.static-sites.do-blog.pages.archive
(:require [com.oly.static-sites.do-blog.routes :refer [post-href]] (:require [clojure.string :as str]
[com.oly.static-sites.do-blog.routes :refer [post-href]]
[com.oly.static-sites.do-blog.pages.helpers.utils :refer [format-date]] [com.oly.static-sites.do-blog.pages.helpers.utils :refer [format-date]]
[com.oly.static-sites.do-blog.pages.helpers.database :refer [search-articles]] [com.oly.static-sites.do-blog.pages.helpers.database :refer [search-articles]]))
[com.oly.static-sites.do-blog.pages.components.core :refer [definition-list]]))
(defn archive-page [{:keys [route search]}] (defn archive-page [{:keys [route]}]
(let [articles (search-articles (merge {:search (:terms search)} (let [tag (-> route :path-params :tag)
(:path-params route)))] articles (search-articles {:tag tag})]
[:div [:div
[:h1 "Past articles"] [:h1.f2 (if (str/blank? tag) "Past articles" (str "Articles tagged " tag))]
(definition-list (if (seq articles)
{:list [:ul.list.pl0.lh-copy
(for [doc articles] (for [{:keys [relative-path date title]} articles]
{:text [:div [:li.mb2 {:replicant/key relative-path}
[:a.f4.lh-copy {:href (post-href (:relative-path doc))} [:time.gray.f6.mr2 {:datetime date} (format-date date)]
(str (format-date (:date doc)) " " (:title doc))]]})})])) [:a.f4.link.blue.hover-green {:href (post-href relative-path)} title]])]
[:p.lh-copy "No articles found."])]))

View File

@ -12,12 +12,6 @@
[com.oly.static-sites.do-blog.views :as views] [com.oly.static-sites.do-blog.views :as views]
[com.oly.static-sites.ui-hiccup.interface :refer [board]])) [com.oly.static-sites.ui-hiccup.interface :refer [board]]))
;;/addwidget https://blog-test.digitaloctave.com/chess?widgetId=dochess
;;/addwidget https://blog-test.digitaloctave.com/chess?roomI=!YOyzcCyoomnjylcOFP:matrix.org&widgetId=dochess
(def widget (atom {}))
#_(def game-state-viking (r/atom {:board viking-start-state}))
(defn chars->map [text] (defn chars->map [text]
(when (= 0 (mod (count text) 4)) (when (= 0 (mod (count text) 4))
@ -191,23 +185,12 @@
(defn chess-page [_state] (defn chess-page [_state]
[:div [:div
(let [[pos piece] (get-selected-square game-state)] [:h1.f2 "Chess"]
[:div [:p.f4.b (if (-> @game-state :player-one :selected)
[:div (str @widget)] "White's turn"
[:div (if (-> @game-state :player-one :selected) "Black's turn")]
"Whites turn"
"Black turn")]
[:div "Player one " (str (mapv :type (-> @game-state :player-one :pieces)))]
[:div "Player two " (str (mapv :type (-> @game-state :player-two :pieces)))]
[:div (str "pos = " pos)]
[:div (str (:type piece))]
[:div (str piece)]
[:div (str "move = " (fetch-selected-piece-moves
[pos piece]
(-> @game-state :board)))]])
[:div (board 8 (-> @game-state :board))] [:div (board 8 (-> @game-state :board))]
[:div "Viking chess board"] [:h2.f3.mt4 "Viking chess"]
[:div (board 11 (-> @v/game-state :board))]]) [:div (board 11 (-> @v/game-state :board))]])
(defmethod views/page :chess [state] (defmethod views/page :chess [state]

View File

@ -18,13 +18,6 @@
[:h1.f3.mb2 name] [:h1.f3.mb2 name]
[:h2.f5.fw4.gray.mt0 tagline]]]) [:h2.f5.fw4.gray.mt0 tagline]]])
(defn definition-list [{:keys [list]}]
[:dl.lh-title.pa4.mt0
(mapcat (fn [{:keys [title text]}]
[[:dt.f6.b title]
[:dd.ml0 text]])
list)])
(defn ui-tags [meta] (defn ui-tags [meta]
[:div [:div
(for [tag (-> meta :filetags extract-tags)] (for [tag (-> meta :filetags extract-tags)]

View File

@ -58,10 +58,10 @@
"Clean up the raw org-meta-index entries ready for datascript." "Clean up the raw org-meta-index entries ready for datascript."
[entries] [entries]
(->> entries (->> entries
;; filter out missing dates (map #(assoc % :tags (vec (:filetags %))
(filter (fn [doc] (some? (:date doc)))) :date (convert-date (:date %))))
(mapv #(assoc % :tags (vec (:filetags %)))) ;; filter out missing or unparseable dates
(mapv #(assoc % :date (convert-date (:date %)))))) (filterv :date)))
(defn load-index! (defn load-index!
"Replace the article database with the parsed index entries." "Replace the article database with the parsed index entries."

View File

@ -1,21 +1,28 @@
(ns com.oly.static-sites.do-blog.pages.helpers.utils (ns com.oly.static-sites.do-blog.pages.helpers.utils
(:require (:require [clojure.string :as str]))
[clojure.string :as str]
[tick.core :as t]
[tick.locale-en-us]
[tick.timezone]))
(defonce date-format (t/formatter "yyyy-MMM-dd")) ;; Dates are kept as ISO "yyyy-MM-dd" strings: they sort correctly as text and
;; avoid pulling a date library (and its timezone data) into the bundle.
(defn format-date [date] (def ^:private month-names
(when date ["Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"])
(t/format date-format date)))
(defn convert-date (defn convert-date
"Convert an org date string like \"2020-06-27 12:00:00 UTC\" to a tick date." "Convert an org date string like \"2020-06-27 12:00:00 UTC\" to \"2020-06-27\".
Returns nil when the text does not start with a valid date."
[text] [text]
(when-not (str/blank? text) (when (string? text)
(-> text str/trim (str/split #" ") first t/date))) (when-let [[_ year month day] (re-find #"^\s*(\d{4})-(\d{2})-(\d{2})" text)]
(let [m (parse-long month)
d (parse-long day)]
(when (and (<= 1 m 12) (<= 1 d 31))
(str year "-" month "-" day))))))
(defn format-date
"Format an ISO date string as \"2020-Jun-27\"."
[date]
(when-let [[_ year month day] (some->> date (re-find #"^(\d{4})-(\d{2})-(\d{2})"))]
(str year "-" (month-names (dec (parse-long month))) "-" day)))
(defn ltrim-slash "Trim a leading slash" [text] (str/replace text #"^/" "")) (defn ltrim-slash "Trim a leading slash" [text] (str/replace text #"^/" ""))

View File

@ -1,9 +0,0 @@
(ns com.oly.static-sites.do-blog.pages.home
(:require [com.oly.static-sites.do-blog.pages.components.core :refer [title-text-image]]))
(defn home-page [{:keys [document]}]
[:div
(title-text-image
{:title (-> document :details :title)
:content (-> document :hiccup)}
(-> document :details))])

View File

@ -21,10 +21,17 @@
(def default-template "bases/do-blog/resources/do-blog/index.template.html") (def default-template "bases/do-blog/resources/do-blog/index.template.html")
(def app-content #"(?s)<!--app-->.*?<!--/app-->") (def app-content #"(?s)<!--app-->.*?<!--/app-->")
(def title-tag #"(?s)<title>.*?</title>")
(defn render-into-template [template html] (defn escape-html [text]
(str/replace template app-content (str/escape (str text) {\& "&amp;" \< "&lt;" \> "&gt;" \" "&quot;"}))
(str/re-quote-replacement (str "<!--app-->" html "<!--/app-->"))))
(defn render-into-template [template title html]
(-> template
(str/replace title-tag
(str/re-quote-replacement (str "<title>" (escape-html title) "</title>")))
(str/replace app-content
(str/re-quote-replacement (str "<!--app-->" html "<!--/app-->")))))
(defn read-document [public-dir relative-path] (defn read-document [public-dir relative-path]
(org->document (slurp (io/file public-dir "documents" relative-path)))) (org->document (slurp (io/file public-dir "documents" relative-path))))
@ -41,7 +48,8 @@
latest (latest-article) latest (latest-article)
tags (->> index (mapcat (comp extract-tags :filetags)) distinct)] tags (->> index (mapcat (comp extract-tags :filetags)) distinct)]
(concat (concat
[["/" (page-state "/" (doc latest))] [["/404.html" {:route nil :search {:terms ""} :not-found? true}]
["/" (page-state "/" (doc latest))]
[(href :about) (page-state (href :about) nil)] [(href :about) (page-state (href :about) nil)]
[(href :chess) (page-state (href :chess) nil)] [(href :chess) (page-state (href :chess) nil)]
[(archive-href "") (page-state (archive-href "") nil)]] [(archive-href "") (page-state (archive-href "") nil)]]
@ -53,8 +61,13 @@
url (post-href path)]] url (post-href path)]]
[url (page-state url (doc path))])))) [url (page-state url (doc path))]))))
(defn url->file [public-dir url] (defn url->file
(io/file public-dir (str (str/replace url #"^/" "") "index.html"))) "Directory style URLs map to <url>/index.html, explicit .html URLs as is."
[public-dir url]
(let [path (str/replace url #"^/" "")]
(io/file public-dir (if (str/ends-with? path ".html")
path
(str path "index.html")))))
(defn generate! (defn generate!
([] (generate! default-public-dir default-template)) ([] (generate! default-public-dir default-template))
@ -66,7 +79,9 @@
(try (try
(let [file (url->file public-dir url)] (let [file (url->file public-dir url)]
(io/make-parents file) (io/make-parents file)
(spit file (render-into-template template (rs/render (views/app state)))) (spit file (render-into-template template
(views/page-title state)
(rs/render (views/app state))))
{:url url}) {:url url})
(catch Exception e (catch Exception e
{:url url :error (ex-message e)})))) {:url url :error (ex-message e)}))))

View File

@ -6,21 +6,63 @@
[com.oly.static-sites.do-blog.pages.helpers.database :refer [search-articles]] [com.oly.static-sites.do-blog.pages.helpers.database :refer [search-articles]]
[com.oly.static-sites.do-blog.pages.components.core [com.oly.static-sites.do-blog.pages.components.core
:refer [profile-card article-list-author-media-flipped]] :refer [profile-card article-list-author-media-flipped]]
[com.oly.static-sites.do-blog.pages.home :refer [home-page]]
[com.oly.static-sites.do-blog.pages.article :refer [article-page]] [com.oly.static-sites.do-blog.pages.article :refer [article-page]]
[com.oly.static-sites.do-blog.pages.archive :refer [archive-page]] [com.oly.static-sites.do-blog.pages.archive :refer [archive-page]]
[com.oly.static-sites.do-blog.pages.about :refer [about-page]])) [com.oly.static-sites.do-blog.pages.about :refer [about-page]]))
(def site-name "Digital Octave")
(defn page-title
"Document title for the current state, shared by the browser and the
static generator."
[{:keys [route document not-found?]}]
(let [tag (-> route :path-params :tag)
title (if not-found?
"Page not found"
(case (-> route :data :name)
:homepage nil
:posts (-> document :details :title)
:archive (if (str/blank? tag) "Past articles" (str "Articles tagged " tag))
:chess "Chess"
:about "About"
"Page not found"))]
(if (str/blank? title)
site-name
(str title " · " site-name))))
(defmulti page (defmulti page
"Render the body for the current route. Browser-only pages (e.g. chess) "Render the body for the current route. Browser-only pages (e.g. chess)
add their own methods." add their own methods."
(fn [state] (-> state :route :data :name))) (fn [state] (-> state :route :data :name)))
(defmethod page :homepage [state] (home-page state)) ;; The homepage shows the latest article, so both render a document.
(defmethod page :homepage [state] (article-page state))
(defmethod page :posts [state] (article-page state)) (defmethod page :posts [state] (article-page state))
(defmethod page :archive [state] (archive-page state)) (defmethod page :archive [state] (archive-page state))
(defmethod page :about [state] (about-page state)) (defmethod page :about [state] (about-page state))
(defmethod page :default [_state] [:div])
(defn not-found-page []
[:div.measure.lh-copy
[:h1.f2 "Page not found"]
[:p "Sorry, there is nothing at this address. It may have moved, or the link may be wrong."]
[:p
[:a.link.blue.hover-green {:href (href :homepage)} "Go to the latest article"]
" or "
[:a.link.blue.hover-green {:href (href :archive {:tag ""})} "browse past articles"]
"."]])
(defmethod page :default [_state] (not-found-page))
;; The chess board is browser only (pages/chess_board.cljs registers the real
;; method); the static page gets a placeholder until the JavaScript loads.
#?(:clj (defmethod page :chess [_state]
[:p.lh-copy "Loading the chess board…"]))
(defn loading-bar [loading]
(when loading
[:div.fixed.top-0.left-0.w-100.bg-green.white.f6.tc.pa1.z-999
{:role "status"}
"Loading…"]))
(defn ui-search [terms] (defn ui-search [terms]
[:div [:div
@ -30,27 +72,51 @@
:value (or terms "") :value (or terms "")
:on {:input [[:search/set-terms :event.target/value]]}}]]) :on {:input [[:search/set-terms :event.target/value]]}}]])
(defn nav-link [route-name params text] (def nav-items
[:li.lh-copy.pv3.b--black-30.ba.bt-0.bl-0.br-0 [{:route :homepage :text "Home"}
[:a.black.f3.link.hover-green {:href (href route-name params)} text]]) {:route :archive :params {:tag ""} :text "Past articles"}
{:route :chess :text "Chess"}
{:route :about :text "About"}])
(defn sidebar [] (defn active?
"Is the nav item for the route currently shown?"
[current-route item]
(= (:route item) (-> current-route :data :name)))
(defn sidebar [current-route]
[:div [:div
(profile-card {:name "Oly" (profile-card {:name "Oly"
:tagline "Earthling, Software Engineer" :tagline "Earthling, Software Engineer"
:img-src "/images/default/me.png"}) :img-src "/images/default/me.png"
:img-alt "Photo of Oly"})
[:ul.list.pl0.measure.center [:ul.list.pl0.measure.center
(nav-link :homepage nil "Home") (for [{:keys [route params text] :as item} nav-items]
(nav-link :archive {:tag ""} "Past articles") [:li.lh-copy.pv3.b--black-30.ba.bt-0.bl-0.br-0 {:replicant/key route}
(nav-link :chess nil "Chess") [:a.f3.link.hover-green
(nav-link :about nil "About")]]) {:href (href route params)
:class (if (active? current-route item) "white" "black")}
text]])]])
(defn layout [{:keys [search]} content] (defn top-bar
"Compact navigation for small screens, where the sidebar is hidden."
[current-route]
[:nav.db.dn-l.bg-blue.pa3
[:a.white.f4.b.link.db.mb2 {:href (href :homepage)} site-name]
(for [{:keys [route params text] :as item} nav-items]
[:a.dib.mr3.f5.link.hover-green
{:replicant/key route
:href (href route params)
:class (if (active? current-route item) "white b" "black")}
text])])
(defn layout [{:keys [route search loading]} content]
(let [terms (:terms search)] (let [terms (:terms search)]
[:div.font.h-100 [:div.font.h-100
(loading-bar loading)
(top-bar route)
[:div.h-100.flex.items-stretch [:div.h-100.flex.items-stretch
[:div.dn.db-l.pa3.bg-blue {:style {:flex-basis "20rem" :flex-grow "1"}} [:div.dn.db-l.pa3.bg-blue {:style {:flex-basis "20rem" :flex-grow "1"}}
(sidebar)] (sidebar route)]
[:div.ma3.pa3 {:style {:flex-basis "0" :flex-grow "999"}} [:div.ma3.pa3 {:style {:flex-basis "0" :flex-grow "999"}}
(ui-search terms) (ui-search terms)
(if (str/blank? terms) (if (str/blank? terms)
@ -60,4 +126,6 @@
(search-articles {:search terms})))]]])) (search-articles {:search terms})))]]]))
(defn app [state] (defn app [state]
(layout state (page state))) (layout state (if (:not-found? state)
(not-found-page)
(page state))))

View File

@ -29,7 +29,6 @@
org.clojure/clojurescript {:mvn/version "1.12.134"} org.clojure/clojurescript {:mvn/version "1.12.134"}
no.cjohansen/replicant {:mvn/version "2026.07.1"} no.cjohansen/replicant {:mvn/version "2026.07.1"}
tick/tick {:mvn/version "0.5.0"}
metosin/reitit {:mvn/version "0.5.18"} metosin/reitit {:mvn/version "0.5.18"}
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"} cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}