1
0
Tienson Qin 4 жил өмнө
parent
commit
2391e723a4

+ 2 - 4
src/main/frontend/components/block.cljs

@@ -1494,10 +1494,8 @@
      (cond->
       {:id block-id
        :data-refs (let [refs (model/get-page-names-by-ids
-                              (map :db/id refs-with-children))
-                        refs (map (fn [ref] (str "\"" ref "\"")) refs)]
-                    (util/format "[%s]"
-                                 (string/join ", " refs)))
+                              (map :db/id refs-with-children))]
+                    (text/build-data-value refs))
        :style {:position "relative"}
        :class (str uuid
                    (when dummy? " dummy")

+ 13 - 4
src/main/frontend/components/journal.cljs

@@ -9,6 +9,7 @@
             [frontend.handler.page :as page-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.db :as db]
+            [frontend.db.model :as model]
             [frontend.state :as state]
             [frontend.ui :as ui]
             [frontend.config :as config]
@@ -21,7 +22,8 @@
             [frontend.components.onboarding :as onboarding]
             [goog.object :as gobj]
             [clojure.string :as string]
-            [frontend.handler.block :as block-handler]))
+            [frontend.handler.block :as block-handler]
+            [frontend.text :as text]))
 
 (rum/defc blocks-inner < rum/static
   {:did-mount (fn [state]
@@ -74,14 +76,21 @@
         intro? (and (not (state/logged?))
                     (not (config/local-db? repo))
                     (not config/publishing?)
-                    today?)]
-    [:div.flex-1.journal.page {:class (if intro? "intro" "")}
+                    today?)
+        page-entity (db/pull [:page/name (string/lower-case title)])
+        data-page-tags (when (seq (:page/tags page-entity))
+                         (let [page-names (model/get-page-names-by-ids (map :db/id (:page/tags page)))]
+                           (text/build-data-value page-names)))]
+    [:div.flex-1.journal.page (cond->
+                               {:class (if intro? "intro" "")}
+                                data-page-tags
+                                (assoc :data-page-tags data-page-tags))
      (ui/foldable
       [:a.initial-color.title
        {:href     (rfe/href :page {:name page})
         :on-click (fn [e]
                     (when (gobj/get e "shiftKey")
-                      (when-let [page (db/pull [:page/name (string/lower-case title)])]
+                      (when-let [page page-entity]
                         (state/sidebar-add-block!
                          (state/get-current-repo)
                          (:db/id page)

+ 6 - 1
src/main/frontend/components/page.cljs

@@ -22,6 +22,7 @@
             [frontend.components.project :as project]
             [frontend.config :as config]
             [frontend.db :as db]
+            [frontend.db.model :as model]
             [frontend.db.utils :as db-utils]
             [frontend.mixins :as mixins]
             [frontend.db-mixins :as db-mixins]
@@ -36,6 +37,7 @@
             [cljs.pprint :as pprint]
             [frontend.context.i18n :as i18n]
             [reitit.frontend.easy :as rfe]
+            [frontend.text :as text]
             [frontend.handler.block :as block-handler]))
 
 (defn- get-page-name
@@ -288,7 +290,10 @@
               developer-mode? (state/sub [:ui/developer-mode?])
               published? (= "true" (:published properties))
               public? (= "true" (:public properties))]
-          [:div.flex-1.page.relative
+          [:div.flex-1.page.relative (if (seq (:page/tags page))
+                                       (let [page-names (model/get-page-names-by-ids (map :db/id (:page/tags page)))]
+                                         {:data-page-tags (text/build-data-value page-names)})
+                                       {})
            [:div.relative
             (when (and (not block?)
                        (not sidebar?)

+ 6 - 0
src/main/frontend/text.cljs

@@ -251,3 +251,9 @@
               body (drop-while properties? properties-and-body)]
           (->> (concat title-lines new-properties body)
                (string/join "\n")))))))
+
+(defn build-data-value
+  [col]
+  (let [items (map (fn [item] (str "\"" item "\"")) col)]
+    (util/format "[%s]"
+                 (string/join ", " items))))