Skip to content

Commit 5ffa6da

Browse files
committed
Don't embed :path->doc in state for :render-router :fetch-edn
1 parent 4b03415 commit 5ffa6da

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/nextjournal/clerk/view.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
;; https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
7272
(str/replace s "</script>" "</nextjournal.clerk.view/escape-closing-script-tag>"))
7373

74-
(defn ->html [{:as state :keys [conn-ws? current-path html exclude-js?]}]
74+
(defn ->html [{:as state :keys [conn-ws? current-path html exclude-js? render-router]}]
7575
(hiccup/html5
7676
[:head
7777
[:meta {:charset "UTF-8"}]
@@ -93,7 +93,7 @@
9393
[:div#clerk html]
9494
(when-not exclude-js?
9595
[:script {:type "module"} "let viewer = nextjournal.clerk.sci_env
96-
let state = " (-> state v/->edn escape-closing-script-tag pr-str) ".replaceAll('nextjournal.clerk.view/escape-closing-script-tag', 'script')
96+
let state = " (-> (if (= render-router :fetch-edn) (dissoc state :path->doc) state) v/->edn escape-closing-script-tag pr-str) ".replaceAll('nextjournal.clerk.view/escape-closing-script-tag', 'script')
9797
viewer.init(viewer.read_string(state))\n"
9898
(when conn-ws?
9999
"viewer.connect(document.location.origin.replace(/^http/, 'ws') + '/_ws')\n")])]))

test/nextjournal/clerk/builder_test.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
:report-fn identity})
7474
(slurp (fs/file temp-dir "index.html")))]
7575
(is (str/includes? html-out "<meta content=\"🔫 My OG Title\" property=\"og:title\">"))
76-
(is (str/includes? html-out "<meta content=\"https://clerk.vision/my-open-graph-url\" property=\"og:url\">")))))
76+
(is (str/includes? html-out "<meta content=\"https://clerk.vision/my-open-graph-url\" property=\"og:url\">"))
77+
(is (not (str/includes? html-out ":path->doc"))))))
7778

7879
(utils/when-not-bb
7980
(testing "image is saved to _data dir"

0 commit comments

Comments
 (0)