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

This commit is contained in:
Daniel 2025-05-31 17:50:59 +08:00
parent 669b2884b1
commit 5e040323f6
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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