File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 192
192
193
193
(defn ->file-or-ns [nav-path]
194
194
(cond (str/starts-with? nav-path " '" ) (symbol (subs nav-path 1 ))
195
- :else nav-path))
195
+ ( re-find #" \. (cljc?|md)$" nav-path) nav-path))
196
196
197
197
(defn show! [opts file-or-ns]
198
198
((resolve 'nextjournal.clerk/show!) opts file-or-ns))
213
213
:headers {" Location" (or (:nav-path @!doc)
214
214
(->nav-path 'nextjournal.clerk.home))}}
215
215
:else
216
- (do
217
- (try (show! {:skip-history? true } (->file-or-ns nav-path))
218
- (catch Exception _))
219
- {:status 200
220
- :headers {" Content-Type" " text/html" " Cache-Control" " no-store" }
221
- :body (view/->html {:doc (view/doc->viewer @!doc)
222
- :resource->url @config/!resource->url
223
- :conn-ws? true })}))))
216
+ (if-let [file-or-ns (->file-or-ns nav-path)]
217
+ (do (try (show! {:skip-history? true } file-or-ns)
218
+ (catch Exception _))
219
+ {:status 200
220
+ :headers {" Content-Type" " text/html" " Cache-Control" " no-store" }
221
+ :body (view/->html {:doc (view/doc->viewer @!doc)
222
+ :resource->url @config/!resource->url
223
+ :conn-ws? true })})
224
+ {:status 404
225
+ :headers {" Content-Type" " text/plain" }
226
+ :body (format " Could not find notebook at %s." (pr-str nav-path))}))))
224
227
225
228
(defn app [{:as req :keys [uri]}]
226
229
(if (:websocket? req)
You can’t perform that action at this time.
0 commit comments