diff --git a/.gitignore b/.gitignore index 7d9456f95..f8b315e20 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ clerk.iml public/girouette.css public/images/ yarn.lock +*~ diff --git a/deps.edn b/deps.edn index f7b366101..62cc0659e 100644 --- a/deps.edn +++ b/deps.edn @@ -31,7 +31,7 @@ :dev {:extra-deps {arrowic/arrowic {:mvn/version "0.1.1"} binaryage/devtools {:mvn/version "1.0.3"} cider/cider-nrepl {:mvn/version "0.26.0"} - thheller/shadow-cljs {:mvn/version "2.15.9"}} + thheller/shadow-cljs {:mvn/version "2.16.7"}} :extra-paths ["dev"] :jvm-opts ["-Dclerk.live_js=true" "-XX:-OmitStackTraceInFastThrow"] :main-opts ["-m" "shadow.cljs.devtools.cli"]} diff --git a/package.json b/package.json index 2487b4580..e4c9ea4d0 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "react-dom": "^17.0.2" }, "devDependencies": { - "shadow-cljs": "^2.15.13", + "shadow-cljs": "^2.16.7", "tailwindcss": "2.2.12" } } diff --git a/src/nextjournal/clerk.clj b/src/nextjournal/clerk.clj index 8ab28d4b5..3564e7e1a 100644 --- a/src/nextjournal/clerk.clj +++ b/src/nextjournal/clerk.clj @@ -175,11 +175,24 @@ (webserver/show-error! e) (throw e)))) +(defn supported-file? + "Returns whether `path` points to a file that should be shown." + [path] + ;; file names starting with .# are most likely Emacs lock files and should be ignored. + (->> path io/file .getName + (re-matches #"(?!^\.#).+\.(md|clj|cljc)$") + some?)) + +#_(supported-file? "foo_bar.clj") +#_(supported-file? "xyz/foo.md") +#_(supported-file? "xyz/foo.clj") +#_(supported-file? "xyz/abc.#name.cljc") +#_(supported-file? ".#name.clj") +#_(supported-file? "xyz/.#name.cljc") + (defn file-event [{:keys [type path]}] (when (and (contains? #{:modify :create} type) - (or (str/ends-with? path ".md") - (str/ends-with? path ".clj") - (str/ends-with? path ".cljc"))) + (supported-file? path)) (binding [*ns* (find-ns 'user)] (let [rel-path (str/replace (str path) (str (fs/canonicalize ".") fs/file-separator) "") show-file? (or (not @!show-filter-fn)