Skip to content

Commit 0de032d

Browse files
zampinomk
andauthored
Fix Images in slideshow viewer (#450)
Fixes serving blob objects in cases where the presented document doesn't contain a `:blocks` key. This happens with a custom notebook viewer as e.g. in the slideshow viewer. Co-authored-by: Martin Kavalar <[email protected]>
1 parent 0dbb91e commit 0de032d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

notebooks/slideshow.clj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
(clerk/plotly {:data [{:z [[1 2 3] [3 2 1]] :type "surface"}]})
1919

2020
;; ---
21-
2221
;; ## 📈 Vega Lite
2322
^{::clerk/visibility {:code :hide}}
2423
(clerk/vl {:width 650 :height 400 :data {:url "https://vega.github.io/vega-datasets/data/us-10m.json"
@@ -27,5 +26,10 @@
2726
:key "id" :fields ["rate"]}}]
2827
:projection {:type "albersUsa"} :mark "geoshape" :encoding {:color {:field "rate" :type "quantitative"}}})
2928

29+
;; ---
30+
;; ## 🖼️ An Image
31+
^{::clerk/visibility {:code :hide}}
32+
(clerk/image "trees.png")
33+
3034
;; ---
3135
;; # 👋🏻 Fin.

src/nextjournal/clerk/webserver.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@
7575
(defn blob->presented [presented-doc]
7676
;; TODO: store on doc?
7777
(into {}
78-
(comp (filter #(and (map? %) (contains? % :nextjournal/presented)))
78+
(comp (filter #(and (map? %) (v/get-safe % :nextjournal/blob-id) (v/get-safe % :nextjournal/presented)))
7979
(map (juxt :nextjournal/blob-id :nextjournal/presented)))
8080
(tree-seq coll? seq
81-
(-> presented-doc v/->value :blocks))))
81+
(:nextjournal/value presented-doc))))
8282

8383
#_(blob->presented (meta @!doc))
8484

0 commit comments

Comments
 (0)