mirror of https://github.com/logseq/logseq
fix: named heading route for file and db graphs
parent
00e153e866
commit
d3c276ac50
|
@ -158,23 +158,19 @@ independent of format as format specific heading characters are stripped"
|
|||
(defn get-block-by-page-name-and-block-route-name
|
||||
"Returns first block for given page name and block's route name. Block's route
|
||||
name must match the content of a page's block header"
|
||||
[repo page-name route-name]
|
||||
[repo page-uuid-str route-name]
|
||||
(let [db (conn/get-db repo)]
|
||||
(if (config/db-based-graph? repo)
|
||||
(->> (d/q '[:find (pull ?b [:block/uuid])
|
||||
:in $ ?page-name ?route-name ?content-matches
|
||||
:in $ ?page-uuid ?route-name ?content-matches %
|
||||
:where
|
||||
[?page :block/name ?page-name]
|
||||
[?page :block/uuid ?page-uuid]
|
||||
[?b :block/page ?page]
|
||||
[?b :block/properties ?prop]
|
||||
[?prop-b :block/name "heading"]
|
||||
[?prop-b :block/type "property"]
|
||||
[?prop-b :block/uuid ?prop-uuid]
|
||||
[(get ?prop ?prop-uuid) _]
|
||||
(has-property ?b :logseq.property/heading)
|
||||
[?b :block/content ?content]
|
||||
[(?content-matches ?content ?route-name ?b)]]
|
||||
db
|
||||
page-name
|
||||
(uuid page-uuid-str)
|
||||
route-name
|
||||
(fn content-matches? [block-content external-content block-id]
|
||||
(let [block (db-utils/entity repo block-id)
|
||||
|
@ -183,20 +179,21 @@ independent of format as format specific heading characters are stripped"
|
|||
(db-content/special-id-ref->page-ref ref-tags)
|
||||
(db-content/special-id-ref->page ref-tags)
|
||||
heading-content->route-name)
|
||||
(string/lower-case external-content)))))
|
||||
(string/lower-case external-content))))
|
||||
(rules/extract-rules rules/db-query-dsl-rules [:has-property]))
|
||||
ffirst)
|
||||
|
||||
(->> (d/q '[:find (pull ?b [:block/uuid])
|
||||
:in $ ?page-name ?route-name ?content-matches
|
||||
:in $ ?page-uuid ?route-name ?content-matches
|
||||
:where
|
||||
[?page :block/name ?page-name]
|
||||
[?page :block/uuid ?page-uuid]
|
||||
[?b :block/page ?page]
|
||||
[?b :block/properties ?prop]
|
||||
[(get ?prop :heading) _]
|
||||
[?b :block/content ?content]
|
||||
[(?content-matches ?content ?route-name)]]
|
||||
db
|
||||
page-name
|
||||
(uuid page-uuid-str)
|
||||
route-name
|
||||
(fn content-matches? [block-content external-content]
|
||||
(= (heading-content->route-name block-content)
|
||||
|
|
Loading…
Reference in New Issue