diff --git a/web/src/main/frontend/components/hiccup.cljs b/web/src/main/frontend/components/hiccup.cljs index abd085e92..f12fff4a3 100644 --- a/web/src/main/frontend/components/hiccup.cljs +++ b/web/src/main/frontend/components/hiccup.cljs @@ -168,32 +168,37 @@ (util/format "\\(%s\\)" s) ["Target" s] - [:span - [:span.text-gray-500 "<<"] - [:a {:href (str "/page/" (util/url-encode s))} s] - [:span.text-gray-500 ">>"]] + [:a {:id s} s] ["Radio_Target" s] - [:a {:href (str "/page/" (util/url-encode s))} (str "<<<" s ">>>")] + [:a {:id s} s] + ;; [:a {:href (str "/page/" (util/url-encode s))} (str "<<<" s ">>>")] ["Link" link] (let [{:keys [url label]} link] - (let [href (string-of-url url) - img-formats (set (map name (config/img-formats)))] - (if (some (fn [fmt] (re-find (re-pattern (str "\\." fmt)) href)) img-formats) - (image-link url href label) - (let [[href label] (match url - ["Search" s] - [(str "#" (anchor-link s)) - s] - :else - [href - (map-inline label)])] + (match url + ["Search" s] + (case (first s) + \# + (->elem :a {:href (str "#" (anchor-link (subs s 1)))} (map-inline label)) + ;; FIXME: same headline, see more https://orgmode.org/manual/Internal-Links.html + \* + (->elem :a {:href (str "#" (anchor-link (subs s 1)))} (map-inline label)) + ;; page reference + [:span.page-reference + [:span.text-gray-500 "[["] + [:a {:href (str "/page/" (util/url-encode s))} s] + [:span.text-gray-500 "]]"]]) + :else + (let [href (string-of-url url) + img-formats (set (map name (config/img-formats)))] + (if (some (fn [fmt] (re-find (re-pattern (str "\\." fmt)) href)) img-formats) + (image-link url href label) (->elem :a {:href href} - label))))) + (map-inline label)))))) ["Verbatim" s] [:code s] diff --git a/web/src/main/frontend/format/org/block.cljs b/web/src/main/frontend/format/org/block.cljs index 12571585f..87bc6aa4d 100644 --- a/web/src/main/frontend/format/org/block.cljs +++ b/web/src/main/frontend/format/org/block.cljs @@ -9,11 +9,14 @@ (vector? block) (= "Heading" (first block)))) -(defn target-block? +(defn page-reference-block? [block] (and (vector? block) - (contains? #{"Target" "Radio_Target"} (first block)))) + (= "Link" (first block)) + (= "Search" (first (:url (second block)))) + (not (contains? #{\# \*} (first (second (:url (second block)))))) + )) (defn task-block? [block] @@ -64,8 +67,9 @@ (let [ref-pages (atom [])] (walk/postwalk (fn [form] - (when (target-block? form) - (swap! ref-pages conj (string/capitalize (last form)))) + (when (page-reference-block? form) + (let [page (second (:url (second form)))] + (swap! ref-pages conj (string/capitalize page)))) form) (concat title children)) (assoc heading :ref-pages (vec @ref-pages)))) diff --git a/web/src/main/frontend/page.cljs b/web/src/main/frontend/page.cljs index c61f0160a..73db92e90 100644 --- a/web/src/main/frontend/page.cljs +++ b/web/src/main/frontend/page.cljs @@ -10,22 +10,27 @@ (rum/defc current-page < rum/reactive [] - (let [route-match (state/sub :route-match)] - (if route-match - (let [route-name (get-in route-match [:data :name]) - no-animate? (contains? #{:repos :repo-add :file} - route-name)] - (when-let [view (:view (:data route-match))] - (sidebar/sidebar - route-match - (if no-animate? - (route-view view route-match) - (ui/transition-group - {:class-name "router-wrapper"} - (ui/css-transition - {:class-names "pageChange" - :key route-name - :timeout {:enter 300 - :exit 200}} - (route-view view route-match))))))) + (when-let [route-match (state/sub :route-match)] + (if-let [view (:view (:data route-match))] + (sidebar/sidebar + route-match + (view route-match)) + + ;; FIXME: disable for now + ;; (let [route-name (get-in route-match [:data :name]) + ;; no-animate? (contains? #{:repos :repo-add :file} + ;; route-name)] + ;; (when-let [view (:view (:data route-match))] + ;; (sidebar/sidebar + ;; route-match + ;; (if no-animate? + ;; (route-view view route-match) + ;; (ui/transition-group + ;; {:class-name "router-wrapper"} + ;; (ui/css-transition + ;; {:class-names "pageChange" + ;; :key route-name + ;; :timeout {:enter 300 + ;; :exit 200}} + ;; (route-view view route-match))))))) [:div "404 Page"])))