Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 11, 2024
1 parent 67b03cd commit dd97da2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/nextjournal/clerk/builder.clj
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@
"Shells out to node to generate server-side-rendered html."
[{:as static-app-opts :keys [report-fn resource->url]}]
(report-fn {:stage :ssr})
(let [{duration :time-ms :keys [result]}
(let [doc (get (:path->doc static-app-opts) (:current-path static-app-opts))
static-app-opts (-> (assoc static-app-opts :doc doc)
(dissoc :path->doc)
(assoc :render-router :serve))
{duration :time-ms :keys [result]}
(eval/time-ms (sh {:in (str "import '" (resource->url "/js/viewer.js") "';"
"console.log(nextjournal.clerk.sci_env.ssr(" (pr-str (pr-str static-app-opts)) "))")}
"node"
Expand All @@ -176,14 +180,8 @@
"--input-type=module"
"--trace-warnings"))
{:keys [out err exit]} result]
(println "Static app Opts")
(println "---")
(prn static-app-opts)
(println "---")
(println "SSR output")
(println "---")
(println result)
(println "---")
#_(def s static-app-opts)
#_(prn static-app-opts)
(if (= 0 exit)
(do
(report-fn {:stage :done :duration duration})
Expand All @@ -210,10 +208,11 @@
(fs/create-dirs (fs/parent out-html))
(spit (fs/file out-path (str (or (not-empty path) "index") ".edn"))
(viewer/->edn doc))
(prn :p path)
(spit out-html (view/->html (-> static-app-opts
(dissoc :path->doc)
(assoc :current-path path)
(cond-> ssr? ssr!)
(dissoc :path->doc)
cleanup))))))
(when browse?
(browse/browse-url (if-let [server-url (and (= out-path "public/build") (webserver/server-url))]
Expand Down Expand Up @@ -363,6 +362,7 @@
;; test against cljs release `bb build:js`
:resource->url {"/js/viewer.js" "./build/viewer.js"}
:index "notebooks/rule_30.clj"})
(spit "/tmp/foo.edn" s)

(build-static-app! {:ssr? true
:compile-css? true
Expand Down
2 changes: 1 addition & 1 deletion src/nextjournal/clerk/render.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@

(defn ^:export set-state! [{:as state :keys [doc effects]}]
(run-effects! effects)
(when (contains? state :doc)
(when doc
(when (exists? js/window)
;; TODO: can we restore the scroll position when navigating back?
(.scrollTo js/window #js {:top 0}))
Expand Down
4 changes: 4 additions & 0 deletions src/nextjournal/clerk/render/hooks.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
(WrappedState. (react/useState init)))

(defn- specify-atom! [ref-obj]
#_(js/console.log "ref" ref-obj (js/Object.isFrozen ref-obj))
#_(prn :ref ref-obj)
(specify! ref-obj
IDeref
(-deref [^js this] (.-current this))
Expand All @@ -72,6 +74,8 @@
([o f a b] (reset! o (f o a b)))
([o f a b xs] (reset! o (apply f o a b xs))))))

#_(prn :specify (specify-atom! (doto #js {} (js/Object.freeze))))

(defn use-ref
"React hook: useRef. Can also be used like an atom."
([] (use-ref nil))
Expand Down

0 comments on commit dd97da2

Please sign in to comment.