Skip to content

Drop emoji-regex require #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/nextjournal/clerk/render.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@

(defn toc-items [items]
(reduce
(fn [acc {:as item :keys [content children attrs]}]
(fn [acc {:as item :keys [content children attrs emoji]}]
(if content
(let [title (md.transform/->text item)]
(->> {:title title
:emoji emoji
:path (str "#" (:id attrs))
:items (toc-items children)}
(conj acc)
Expand Down
11 changes: 3 additions & 8 deletions src/nextjournal/clerk/render/navbar.cljs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
(ns nextjournal.clerk.render.navbar
(:require ["emoji-regex" :as emoji-regex]
["framer-motion" :as framer-motion :refer [motion AnimatePresence]]
(:require ["framer-motion" :as framer-motion :refer [motion AnimatePresence]]
[nextjournal.clerk.render.localstorage :as localstorage]
[applied-science.js-interop :as j]
[clojure.string :as str]
[reagent.core :as r]))

(def emoji-re (emoji-regex))

(defn stop-event! [event]
(.preventDefault event)
(.stopPropagation event))
Expand Down Expand Up @@ -74,10 +71,8 @@
(into
[:div]
(map-indexed
(fn [i {:keys [path title expanded? loading? items toc]}]
(let [label (or title (str/capitalize (last (str/split path #"/"))))
emoji (when (zero? (.search label emoji-re))
(first (.match label emoji-re)))]
(fn [i {:keys [emoji path title expanded? loading? items toc]}]
(let [label (or title (str/capitalize (last (str/split path #"/"))))]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that we never call navbar-items at runtime in the current usage of navbar in Clerk. @joe-loco could you have a look? We're passing a :toc to the navbar state and not :items.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed this with @mk in Berlin. I initially wanted to drop all code that was not relevant to :toc but @mk wanted to keep it in for when Clerk is able to show hierarchies that are above notebooks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can discuss further when I’m back tmw if you want.

[:<>
(if (seq items)
[:div.flex.cursor-pointer
Expand Down