Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve backlink filtering below the heading https://github.com/siyuan-note/siyuan/issues/14929

Daniel5e040323f684
diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go
index 9f38e28196..edb623991f 100644
--- a/kernel/model/backlink.go
+++ b/kernel/model/backlink.go
@@ -682,7 +682,7 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret []
if matchBacklinkKeyword(child, keywords) {
heading := headingRefChildren[child.ParentID]
- if nil != heading {
+ if nil != heading && !existBlock(heading, ret) {
ret = append(ret, heading)
}
}
@@ -691,6 +691,15 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret []
return
}
+func existBlock(block *Block, blocks []*Block) bool {
+ for _, b := range blocks {
+ if block.ID == b.ID {
+ return true
+ }
+ }
+ return false
+}
+
func matchBacklinkKeyword(block *Block, keywords []string) bool {
if 1 > len(keywords) {
return true